|
DSA Hacking Club Library
|
A simple linked-list-based queue implementation in C. More...
#include <stdbool.h>
Go to the source code of this file.
Classes | |
| struct | node |
| A node in the singly linked list. More... | |
| struct | queue |
| Queue structure. More... | |
Macros | |
| #define | QUEUE_EMPTY (-1) |
| Return code for dequeue when the queue is empty. | |
Typedefs | |
| typedef struct node | node_t |
| Node structure for the queue. | |
Functions | |
| void | init_queue (queue *q) |
| Initialize a queue. | |
| bool | enqueue (queue *q, int value) |
| Insert a new value at the end of the queue. | |
| int | dequeue (queue *q) |
| Remove and return the value at the front of the queue. | |
| void | printqueue (queue *q) |
| Print the contents of the queue to stdout. | |
A simple linked-list-based queue implementation in C.
This header defines the queue structure and its operations such as initialization, enqueue, dequeue, and printing. The queue stores integers.
Node structure for the queue.
Each node stores an integer value and a pointer to the next node.
| int dequeue | ( | queue * | q | ) |
Remove and return the value at the front of the queue.
| [in,out] | q | Pointer to the queue. |
| bool enqueue | ( | queue * | q, |
| int | value ) |
Insert a new value at the end of the queue.
| [in,out] | q | Pointer to the queue. |
| [in] | value | The integer value to enqueue. |
| void init_queue | ( | queue * | q | ) |
Initialize a queue.
Sets the head and tail pointers of the queue to NULL.
| [in,out] | q | Pointer to the queue to initialize. |
| void printqueue | ( | queue * | q | ) |
Print the contents of the queue to stdout.
Each value is printed on a separate line with the format: "t = <value>".
| [in] | q | Pointer to the queue. |