A simple queue data structure. More...
Classes | |
struct | Queue |
A node in the queue. More... | |
Functions | |
bool | queue_is_empty (Queue *queue) |
Checks if the queue is empty. | |
void | queue_push (Queue *queue, void *data) |
Pushes data onto the queue. | |
void * | queue_pop (Queue *queue) |
Pops data from the queue. | |
void | queue_free (Queue *queue) |
Frees the queue. | |
A simple queue data structure.
This module provides a simple queue data structure and functions to manipulate it. The queue is implemented as a singly linked list where each node contains a pointer to the next node and a pointer to the data.
bool queue_is_empty | ( | Queue * | queue | ) |
Checks if the queue is empty.
This function checks if the given queue is empty.
queue | Pointer to the queue to check. |
void queue_push | ( | Queue * | queue, |
void * | data | ||
) |
Pushes data onto the queue.
This function adds a new node with the given data to the end of the queue.
queue | Pointer to the queue to push data onto. |
data | Pointer to the data to be added to the queue. |
void * queue_pop | ( | Queue * | queue | ) |
Pops data from the queue.
This function removes the node at the front of the queue and returns the data stored in that node. If the queue is empty, the behavior is undefined.
queue | Pointer to the queue to pop data from. |
void queue_free | ( | Queue * | queue | ) |
Frees the queue.
This function frees all the nodes in the queue. The data stored in the nodes is not freed.
queue | Pointer to the queue to be freed. |