Queue data structure.
More...
#include "osurs/ds/queue.h"
#include <stdio.h>
#include <stdlib.h>
Queue data structure.
- Date
- : 2022-12-20
- Author
- : Merlin Unterfinger
◆ queue_clear()
void queue_clear |
( |
Queue * |
queue | ) |
|
Clear all elements from a Queue.
This function removes all elements from a Queue, but does not free the queue structure itself.
- Parameters
-
queue | The Queue to be cleared. |
◆ queue_create()
Create a new Queue structure.
This function creates a new Queue structure and returns a pointer to it. The new structure is initialized with its head and tail pointers set to NULL.
- Returns
- A pointer to the new Queue structure.
◆ queue_dequeue()
void* queue_dequeue |
( |
Queue * |
queue | ) |
|
Remove an element from the front of a Queue.
This function removes the element at the front of a Queue and returns a pointer to it. If the queue is empty, the function returns NULL.
- Parameters
-
queue | The Queue from which the element will be removed. |
- Returns
- The element at the front of the queue, or NULL if the queue is empty.
◆ queue_enqueue()
void queue_enqueue |
( |
Queue * |
queue, |
|
|
void * |
data |
|
) |
| |
Add an element to the end of a Queue.
This function adds an element to the end of a Queue. If the queue is empty, the element becomes both the head and the tail of the queue.
- Parameters
-
queue | The Queue to which the element will be added. |
data | The element to be added to the queue. |
◆ queue_free()
void queue_free |
( |
Queue * |
queue | ) |
|
Free a Queue structure.
This function frees a Queue structure, including all nodes and their data.
- Parameters
-
queue | The Queue structure to be freed. |
◆ queue_init()
void queue_init |
( |
Queue * |
queue | ) |
|
Initialize a Queue structure.
This function initializes a Queue structure by setting its head and tail pointers to NULL.
- Parameters
-
queue | The Queue structure to be initialized. |
◆ queue_is_empty()
bool queue_is_empty |
( |
Queue * |
queue | ) |
|
Check if a Queue is empty.
This function checks if a Queue is empty (contains no elements).
- Parameters
-
queue | The Queue to be checked. |
- Returns
- true if the queue is empty, false otherwise.