-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.h
39 lines (27 loc) · 904 Bytes
/
stack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <stdlib.h>
#ifndef STACK_H
#define STACK_H
//https://www.techiedelight.com/stack-implementation/
// Data structure for stack
struct stack
{
int maxsize; // define max capacity of stack
int top;
short *items;
};
// Utility function to initialize stack
struct stack* stack_new(int capacity);
// Utility function to return the size of the stack
int stack_size(struct stack *pt);
// Utility function to check if the stack is empty or not
int stack_isEmpty(struct stack *pt);
// Utility function to check if the stack is full or not
int stack_isFull(struct stack *pt);
// Utility function to add an element x in the stack
void stack_push(struct stack *pt, short x);
// Utility function to return top element in a stack
short stack_peek(struct stack *pt);
// Utility function to pop top element from the stack
short stack_pop(struct stack *pt);
#endif /* STACK_H */