osurs
0.0.1
|
#include <stdbool.h>
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | StackNode |
Stack node. More... | |
struct | Stack |
Stack. More... | |
Typedefs | |
typedef struct StackNode | StackNode |
Stack node. More... | |
typedef struct Stack | Stack |
Stack. More... | |
Functions | |
void | stack_init (Stack *stack) |
Initialize a Stack structure. More... | |
Stack * | stack_create () |
Create a new Stack structure. More... | |
bool | stack_is_empty (Stack *stack) |
Check if a Stack is empty. More... | |
void | stack_push (Stack *stack, void *data) |
Push an element onto a Stack. More... | |
void * | stack_pop (Stack *stack) |
Pop the top element from a Stack. More... | |
void * | stack_peek (Stack *stack) |
Return the top element of a Stack. More... | |
void | stack_clear (Stack *stack) |
Clear all elements from a Stack. More... | |
void | stack_free (Stack *stack) |
Free a Stack structure. More... | |
Stack data structure.
This file defines a Stack data structure, which is an abstract data type (ADT) that implements a LIFO (last-in, first-out) stack. Elements can be inserted at the top and removed from the top.
void stack_clear | ( | Stack * | stack | ) |
Stack* stack_create | ( | ) |
void stack_free | ( | Stack * | stack | ) |
void stack_init | ( | Stack * | stack | ) |
bool stack_is_empty | ( | Stack * | stack | ) |
void* stack_peek | ( | Stack * | stack | ) |
Return the top element of a Stack.
This function returns a pointer to the element at the top of a Stack, without removing it from the stack. If the stack is empty, the function returns NULL.
stack | The Stack from which the top element will be returned. |
void* stack_pop | ( | Stack * | stack | ) |
Pop the top element from a Stack.
This function removes the element at the top of a Stack and returns a pointer to it. If the stack is empty, the function returns NULL.
stack | The Stack from which the element will be removed. |