-
Notifications
You must be signed in to change notification settings - Fork 3
/
stack.h
36 lines (26 loc) · 828 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
#ifndef STACK_H
#define STACK_H
typedef unsigned char byte;
typedef struct Stack {
int top;
byte *storage;
int elemSize;
int maxElements;
} Stack;
/* Function for initializing the Stack */
void init(Stack *s, int elemSize, int maxElements);
/* Function for checking whether the stack is empty */
/* Returns non-zero value if stack is not empty */
int isEmpty(Stack *s);
/* Function for returning number of elements in the stack */
int size(Stack *s);
/* Inserts an element at top of stack */
void push(Stack *s, void *elem);
/* Removes an element from top of stack */
/* Returns a pointer to the element removed */
void* pop(Stack *s);
/* Returns a pointer to the top element without removing it from stack */
void* top(Stack *s);
/* Deallocates the memory allocated to stack */
void destroy(Stack *s);
#endif