Data Structures Lerax  1.1.0
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
stack.h
Go to the documentation of this file.
1
12
13#ifndef STACK_H
14#define STACK_H
15
16#define STACK_STATIC_MAX 10
18
22typedef struct stack Stack;
23
31
40
48void stack_push(Stack* s, int data);
49
58
67bool stack_has(Stack* s, int data);
68
76
85
93
94// additional functions
95
104
113
122
123#endif
int stack_odds(Stack *s)
Counts the number of odd elements in a stack.
void stack_push(Stack *s, int data)
Pushes an element onto the top of a stack.
int stack_pop(Stack *s)
Pops an element from the top of a stack.
bool stack_has(Stack *s, int data)
Check if element is on the stack.
int stack_top(Stack *s)
Returns the element at the top of a stack without removing it.
void stack_print(Stack *s)
Prints the elements of a stack to the console.
void stack_println(Stack *s)
Prints the elements of a stack to the console, followed by a newline character.
int stack_empty(Stack *s)
Checks if a stack is empty.
Iterator * stack_iterator(Stack *s)
Iterator of a stack structure.
Stack * stack_create(void)
Creates an empty stack.
void stack_free(Stack *s)
Frees the memory allocated for a stack.
struct stack Stack
A stack data structure.
Definition stack.h:22
A generic iterator struct.
Definition iterator.h:13