osurs  0.0.1
stack.h
Go to the documentation of this file.
1 
13 #ifndef OSURS_DS_STACK_H_
14 #define OSURS_DS_STACK_H_
15 
16 #include <stdbool.h>
17 #include <stddef.h>
18 
25 typedef struct StackNode {
26  void* data;
27  struct StackNode* next;
29 
37 typedef struct Stack {
39  size_t size;
41 
50 void stack_init(Stack* stack);
51 
62 
71 bool stack_is_empty(Stack* stack);
72 
81 void stack_push(Stack* stack, void* data);
82 
92 void* stack_pop(Stack* stack);
93 
103 void* stack_peek(Stack* stack);
104 
113 void stack_clear(Stack* stack);
114 
122 void stack_free(Stack* stack);
123 
124 #endif // OSURS_DS_STACK_H_
void stack_push(Stack *stack, void *data)
Push an element onto a Stack.
Definition: stack.c:30
void stack_clear(Stack *stack)
Clear all elements from a Stack.
Definition: stack.c:57
void * stack_peek(Stack *stack)
Return the top element of a Stack.
Definition: stack.c:52
Stack * stack_create()
Create a new Stack structure.
Definition: stack.c:18
bool stack_is_empty(Stack *stack)
Check if a Stack is empty.
Definition: stack.c:28
void * stack_pop(Stack *stack)
Pop the top element from a Stack.
Definition: stack.c:42
void stack_init(Stack *stack)
Initialize a Stack structure.
Definition: stack.c:13
struct Stack Stack
Stack.
void stack_free(Stack *stack)
Free a Stack structure.
Definition: stack.c:66
struct StackNode StackNode
Stack node.
Stack node.
Definition: stack.h:25
void * data
Definition: stack.h:26
struct StackNode * next
Definition: stack.h:27
Stack.
Definition: stack.h:37
size_t size
Definition: stack.h:39
StackNode * top
Definition: stack.h:38