|
C Fundamentals
Algorithms · data structures · cryptography · systems — pure C11, zero deps
|
Go to the source code of this file.
Classes | |
| struct | queue |
Macros | |
| #define | QUEUE_INITIAL_CAP 16 |
Functions | |
| queue_t * | queue_create (void) |
| bool | queue_dequeue (queue_t *q, int *out_value) |
| void | queue_destroy (queue_t *q) |
| bool | queue_enqueue (queue_t *q, int value) |
| static bool | queue_grow (queue_t *q) |
| bool | queue_is_empty (const queue_t *q) |
| bool | queue_peek (const queue_t *q, int *out_value) |
| size_t | queue_size (const queue_t *q) |
Circular buffer with head + size. We use head + size (not head + tail) so an empty queue and a full queue are distinguishable without sacrificing one slot.
Definition in file queue.c.
| queue_t * queue_create | ( | void | ) |
Definition at line 22 of file queue.c.
References queue::capacity, queue::data, queue::head, QUEUE_INITIAL_CAP, and queue::size.
| bool queue_dequeue | ( | queue_t * | q, |
| int * | out_value | ||
| ) |
Definition at line 63 of file queue.c.
References queue::capacity, queue::data, queue::head, and queue::size.
| void queue_destroy | ( | queue_t * | q | ) |
Definition at line 33 of file queue.c.
References queue::data.
| bool queue_enqueue | ( | queue_t * | q, |
| int | value | ||
| ) |
Definition at line 54 of file queue.c.
References queue::capacity, queue::data, queue::head, queue_grow(), and queue::size.
|
static |
Definition at line 39 of file queue.c.
References queue::capacity, queue::data, queue::head, and queue::size.
Referenced by queue_enqueue().
| bool queue_is_empty | ( | const queue_t * | q | ) |
Definition at line 78 of file queue.c.
References queue::size.
| bool queue_peek | ( | const queue_t * | q, |
| int * | out_value | ||
| ) |
Definition at line 71 of file queue.c.
References queue::data, queue::head, and queue::size.
| size_t queue_size | ( | const queue_t * | q | ) |
Definition at line 77 of file queue.c.
References queue::size.