|
bglibs
|
Data Structures | |
| struct | gqueue_node |
| struct | gqueue |
Macros | |
| #define | GQUEUE_DECL(PREFIX, TYPE) |
| #define | GQUEUE_PUSH_DEFN(PREFIX, TYPE, COPY) |
| #define | GQUEUE_TOP_DEFN(PREFIX, TYPE) |
| #define | GQUEUE_POP_DEFN(PREFIX, FREE) |
| #define | GQUEUE_DEFN(PREFIX, TYPE, COPY, FREE) |
Functions | |
| int | gqueue_push (struct gqueue *d, unsigned datasize, const void *data, adt_copy_fn *fn) |
| void * | gqueue_top (const struct gqueue *q) |
| void | gqueue_pop (struct gqueue *q, adt_free_fn *fn) |
A generic queue is a first-in-first-out structure defined here based on three primary operations: push, top, and pop. Pushing an element onto a queue adds it to the tail of the list. The top operation fetches the least recently pushed element still on the queue, and popping removes it.
| #define GQUEUE_DECL | ( | PREFIX, | |
| TYPE | |||
| ) |
Declare specialized gqueue functions.
| #define GQUEUE_DEFN | ( | PREFIX, | |
| TYPE, | |||
| COPY, | |||
| FREE | |||
| ) |
Define all the specialized gqueue functions. If COPY is NULL, a simple memcpy is used instead. If FREE is NULL, no attempt is made to free the data.
| #define GQUEUE_POP_DEFN | ( | PREFIX, | |
| FREE | |||
| ) |
Define a specialized gqueue pop function.
| #define GQUEUE_PUSH_DEFN | ( | PREFIX, | |
| TYPE, | |||
| COPY | |||
| ) |
Define a specialized gqueue push function.
| #define GQUEUE_TOP_DEFN | ( | PREFIX, | |
| TYPE | |||
| ) |
Define a specialized gqueue top function.
| void gqueue_pop | ( | struct gqueue * | q, |
| adt_free_fn * | fn | ||
| ) |
Remove the first (least recently pushed) element from the queue. If the free function fn is NULL no data freeing is done. Note that this does not return a pointer to the popped item, as once the item has been popped it is also freed.
References gqueue::count, gqueue_node::data, gqueue::head, gqueue_node::next, and gqueue::tail.
| int gqueue_push | ( | struct gqueue * | q, |
| unsigned | datasize, | ||
| const void * | data, | ||
| adt_copy_fn * | fn | ||
| ) |
Add a new element onto the queue. If the copy function fn is NULL memcpy is used in its place.
References gqueue::count, gqueue_node::data, gqueue::head, gqueue_node::next, and gqueue::tail.
| void* gqueue_top | ( | const struct gqueue * | q | ) |
Return the address of first (least recently pushed) element in the queue.
References gqueue_node::data, and gqueue::head.
1.8.13