Defines | |
#define | QUEUE_NULL ((void *) 0) |
A null QueueValue. | |
Typedefs | |
typedef struct _Queue | Queue |
A double-ended queue. | |
typedef void * | QueueValue |
A value stored in a Queue. | |
Functions | |
Queue * | queue_new (void) |
Create a new double-ended queue. | |
void | queue_free (Queue *queue) |
Destroy a queue. | |
int | queue_push_head (Queue *queue, QueueValue data) |
Add a value to the head of a queue. | |
QueueValue | queue_pop_head (Queue *queue) |
Remove a value from the head of a queue. | |
QueueValue | queue_peek_head (Queue *queue) |
Read value from the head of a queue, without removing it from the queue. | |
int | queue_push_tail (Queue *queue, QueueValue data) |
Add a value to the tail of a queue. | |
QueueValue | queue_pop_tail (Queue *queue) |
Remove a value from the tail of a queue. | |
QueueValue | queue_peek_tail (Queue *queue) |
Read a value from the tail of a queue, without removing it from the queue. | |
int | queue_is_empty (Queue *queue) |
Query if any values are currently in a queue. |
A double ended queue stores a list of values in order. New values can be added and removed from either end of the queue.
To create a new queue, use queue_new. To destroy a queue, use queue_free.
To add values to a queue, use queue_push_head and queue_push_tail.
To read values from the ends of a queue, use queue_pop_head and queue_pop_tail. To examine the ends without removing values from the queue, use queue_peek_head and queue_peek_tail.
void queue_free | ( | Queue * | queue | ) |
Destroy a queue.
queue | The queue to destroy. |
int queue_is_empty | ( | Queue * | queue | ) |
Query if any values are currently in a queue.
queue | The queue. |
Queue* queue_new | ( | void | ) |
Create a new double-ended queue.
QueueValue queue_peek_head | ( | Queue * | queue | ) |
Read value from the head of a queue, without removing it from the queue.
queue | The queue. |
QueueValue queue_peek_tail | ( | Queue * | queue | ) |
Read a value from the tail of a queue, without removing it from the queue.
queue | The queue. |
QueueValue queue_pop_head | ( | Queue * | queue | ) |
Remove a value from the head of a queue.
queue | The queue. |
QueueValue queue_pop_tail | ( | Queue * | queue | ) |
Remove a value from the tail of a queue.
queue | The queue. |
int queue_push_head | ( | Queue * | queue, | |
QueueValue | data | |||
) |
Add a value to the head of a queue.
queue | The queue. | |
data | The value to add. |
int queue_push_tail | ( | Queue * | queue, | |
QueueValue | data | |||
) |
Add a value to the tail of a queue.
queue | The queue. | |
data | The value to add. |