Graphviz 12.0.1~dev.20240716.0800
|
generic first-in-first-out buffer (queue) More...
Go to the source code of this file.
Data Structures | |
struct | queue_t |
Functions | |
static queue_t | queue_new (size_t hint) |
static void | queue_push (queue_t *q, void *item) |
static void * | queue_pop (queue_t *q) |
static void | queue_free (queue_t *q) |
The header-only implementation below defines a queue with an optional initial capacity that expands on-demand if necessary. Expansions always succeed or exit on out-of-memory. A queue item is a generic pointer, void *
.
Definition in file queue.h.
|
inlinestatic |
deallocate backing memory and re-initialize a queue
q | Queue to operate on |
Definition at line 108 of file queue.h.
References queue_t::base, free(), and NULL.
Referenced by build_ranks(), init_rank(), setNStepsToCenter(), and travBFS().
|
inlinestatic |
create a new queue
The hint should be a guess of the intended occupancy ceiling. If the guess is inaccurate, the queue expands on-demand anyway, so there are few consequences for getting it wrong. It is possible to pass 0 as the hint, but in this case you are better of using zero initialization for brevity.
hint | Number of initial slots to allocate |
Definition at line 39 of file queue.h.
References queue_t::base, and gv_calloc().
Referenced by init_rank().
|
inlinestatic |
remove an item from the head of a queue
q | Queue to operate on |
NULL
if the queue was empty Definition at line 90 of file queue.h.
References queue_t::base, queue_t::capacity, queue_t::head, NULL, and queue_t::size.
Referenced by build_ranks(), init_rank(), setNStepsToCenter(), and travBFS().
|
inlinestatic |
insert a new item at the tail of a queue
It is possible to push NULL
entries. But then you will be unable to distinguish popping this entry from the queue being empty.
q | Queue to operate on |
item | Entry to insert |
Definition at line 52 of file queue.h.
References queue_t::base, queue_t::capacity, gv_recalloc(), queue_t::head, NULL, prefix, and queue_t::size.
Referenced by build_ranks(), enqueue_neighbors(), init_rank(), setNStepsToCenter(), and travBFS().