-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.h
More file actions
32 lines (24 loc) · 883 Bytes
/
stack.h
File metadata and controls
32 lines (24 loc) · 883 Bytes
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
#ifndef _STACK_H
#define _STACK_H
typedef char stackElement;
typedef struct {
stackElement *contents;
int top;
int maxSize;
} stackT
void stackInit(stackT *stackP, int maxSize);
// Needs to change stack passed to it. Therefore, stack is passed by reference.
// Allocate space for contents.
// Store maxiumum size.
// Set up top.
// Make sure space was allocated by testing pointer against NULL
void stackDestroy(stackT *stackP);
// Get rid of any dynamically-allocated memory and set stack to reasonable state.
int stackIsEmpty(stackT *stackP);
int stackIsFull(stackT *stackP);
// Don't have to pass by reference, but should to be consistent.
void stackPush(stackT *stackP, stackElementT element);
// Should place element at the top of the stack.
// Should check if the array is not already full.
stackElementT stackPop(stackT *stackP);
#endif /* not defined _STACK_H */