-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.h
More file actions
29 lines (23 loc) · 690 Bytes
/
stack.h
File metadata and controls
29 lines (23 loc) · 690 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
#ifndef STACK_H_
#define STACK_H_
#include <stdbool.h>
#include <stdlib.h>
typedef struct stackNode {
void *item;
struct stackNode *next;
} StackNode;
typedef struct stack {
StackNode *top;
unsigned int len;
size_t itemSize;
bool (* free)(void *item);
} Stack;
bool InitStack(Stack **stack, size_t itemSize, bool (* free)(void *item));
bool FreeStack(Stack *stack);
bool ResetStack(Stack *stack);
bool MakeStackNode(StackNode **node, void *item);
bool FreeStackNode(StackNode *node);
bool PushStackItem(Stack *stack, void *item);
bool PopStackItem(Stack *stack, void * restrict item);
bool TraverseStack(Stack *stack, bool (* invoke)(const void *item));
#endif