QUEUE(3) Library Functions Manual QUEUE(3)

ArrayA simple static queue data structure.

#include <Queue.h>

Queue *

QueueFree(Array *);

QueuePush(Queue *, void *);

void *
QueuePop(Queue *);

void *
QueuePeek(Queue *);

QueueFull(Queue *);

QueueEmpty(Queue *);

These functions implement a simple queue data structure that is statically sized. This implementation does not actually store the values of the items in it; it only stores pointers to the data. As such, you will still have to manually maintain all your data. The advantage of this is that these functions don't have to copy data, and thus don't care how big the data is. Furthermore, arbitrary data can be stored in the queue.

This queue implementation operates on the heap. It is a circular queue, and it does not grow as it is used. Once the size is set, the queue never gets any bigger.

These functions operate on a queue structure which is opaque to the caller.

() and () allocate and deallocate a queue, respectively. Note that QueueFree() does not free any of the values stored in the queue; it is the caller's job to manage the memory for each item. Typically, the caller would dequeue all the items in the queue and free them before freeing the queue itself.

() and () are the main functions used to modify the array. They enqueue and dequeue elements from the queue structure, respectively.

() simply returns the pointer that is next up in the queue without actually discarding it, such that the next call to QueuePeek() or QueuePop() return the same pointer.

() and () return a boolean value that indicates whether or not the queue is full or empty, respectively.

QueueCreate() returns a queue structure, or NULL if there was a memory allocation error.

QueuePush() as well as QueueFull() and QueueEmpty() all return boolean values. In the case of QueuePush() whether or not the push was actually successful is returned. This will only happen if the queue is already full, or a NULL pointer is passed.

QueuePop() and QueuePeek() both return caller-managed pointers that would have been at some point pushed into the queue with the QueuePush() function. They may also return NULL if the queue is empty.

Array(3), HashMap(3)

November 25, 2022 Telodendria Project