Queue

Types

type ymo_queue_t

Generic queue datastructure.

Definition
typedef struct ymo_queue ymo_queue_t;
type ymo_queue_node_t

A queue node.

Definition
typedef struct ymo_queue_node ymo_queue_node_t;

Functions

ymo_queue_t *ymo_queue_create(void)

Allocate an initialize a new ymo queue.

static inline void ymo_queue_init(ymo_queue_t *queue)

Initialize a statically allocated ymo_queue

ymo_queue_t *ymo_queue_create_pool(size_t n)

Create a new ymo queue with a node pool.

void ymo_queue_pool_init(ymo_queue_t *queue, ymo_queue_node_t *pool, size_t n)

Initialize a statically allocated array of queue nodes to be used as a pool for the given queue.

void ymo_queue_free(ymo_queue_t *queue)

Free an ymo queue.

ymo_status_t ymo_queue_append(ymo_queue_t *queue, void *item)

Append an item to the queue.

ymo_status_t ymo_queue_append_queue(ymo_queue_t *dst, ymo_queue_t *src)

Append the contents of src to dst, clearing src:

ymo_status_t ymo_queue_prepend(ymo_queue_t *queue, void *item)

Prepend an item to the queue.

void *ymo_queue_popfront(ymo_queue_t *queue)

Pop the front item off the queue.

void *ymo_queue_peekfront(ymo_queue_t *queue)

Peek the front item in the queue.

void *ymo_queue_popback(ymo_queue_t *queue)

Pop the back item off the queue.

void *ymo_queue_peekback(ymo_queue_t *queue)

Peek the back item in the queue.

const ymo_queue_node_t *ymo_queue_head(ymo_queue_t *queue)

Get the head node of the queue.

const ymo_queue_node_t *ymo_queue_tail(ymo_queue_t *queue)

Get the tail node of the queue.

void *ymo_queue_find(ymo_queue_t *queue, ymo_queue_cmp_fn cmp_fn, void *item)

Find an item using the given comparison function.

ymo_status_t ymo_queue_remove(ymo_queue_t *queue, ymo_queue_node_t **node)

Remove an item from the queue:

size_t ymo_queue_size(ymo_queue_t *queue)

Return the number of items in the queue.