-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.h
46 lines (37 loc) · 979 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
40
41
42
43
44
45
46
#ifndef tinyc_stack_h
#define tinyc_stack_h
#include <stdbool.h>
typedef struct stack_node_t StackNode;
struct stack_node_t {
StackNode *next;
void *value;
};
typedef struct {
StackNode *head;
unsigned long size;
} Stack;
typedef enum stack_iteration_state_t {
SIST_UNKNOWN = 0,
SIST_BEFORE,
SIST_RUNNING,
SIST_AFTER
} StackIterationState;
typedef struct {
Stack *stack;
StackNode *current;
StackIterationState state;
} StackIterator;
Stack *Stack_new();
void Stack_delete(Stack *stack);
unsigned long Stack_size(Stack *stack);
bool Stack_isEmpty(Stack *stack);
void Stack_push(Stack *stack, void *value);
void *Stack_pop(Stack *stack);
StackIterator *Stack_iterator(Stack *stack);
StackNode *StackNode_new(void *value);
void StackNode_delete(StackNode *node);
StackIterator *StackIter_new(Stack *stack);
void StackIter_delete(StackIterator *iter);
void *StackIter_current(StackIterator *iter);
bool StackIter_moveNext(StackIterator *iter);
#endif