|
bglibs
|
Data Structures | |
| struct | gstack_node |
| struct | gstack |
Macros | |
| #define | GSTACK_DECL(PREFIX, TYPE) |
| #define | GSTACK_PUSH_DEFN(PREFIX, TYPE, COPY) |
| #define | GSTACK_TOP_DEFN(PREFIX, TYPE) |
| #define | GSTACK_POP_DEFN(PREFIX, FREE) |
| #define | GSTACK_DEFN(PREFIX, TYPE, COPY, FREE) |
Functions | |
| int | gstack_push (struct gstack *d, unsigned datasize, const void *data, adt_copy_fn *fn) |
| void * | gstack_top (const struct gstack *s) |
| void | gstack_pop (struct gstack *s, adt_free_fn *fn) |
A generic stack is a first-in-last-out structure defined here based on three primary operations: push, top, and pop. Pushing an element onto a stack adds it to the head of the list. The top operation fetches the most recently pushed element still on the stack, and popping removes it.
| #define GSTACK_DECL | ( | PREFIX, | |
| TYPE | |||
| ) |
Declare specialized gstack functions.
| #define GSTACK_DEFN | ( | PREFIX, | |
| TYPE, | |||
| COPY, | |||
| FREE | |||
| ) |
Define all the specialized gstack functions. If COPY is NULL, a simple memcpy is used instead. If FREE is NULL, no attempt is made to free the data.
| #define GSTACK_POP_DEFN | ( | PREFIX, | |
| FREE | |||
| ) |
Define a specialized gstack pop function.
| #define GSTACK_PUSH_DEFN | ( | PREFIX, | |
| TYPE, | |||
| COPY | |||
| ) |
Define a specialized gstack push function.
| #define GSTACK_TOP_DEFN | ( | PREFIX, | |
| TYPE | |||
| ) |
Define a specialized gstack top function.
| void gstack_pop | ( | struct gstack * | s, |
| adt_free_fn * | fn | ||
| ) |
Remove the first (most 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 gstack::count, gstack_node::data, gstack::head, and gstack_node::next.
| int gstack_push | ( | struct gstack * | s, |
| unsigned | datasize, | ||
| const void * | data, | ||
| adt_copy_fn * | fn | ||
| ) |
Add a new element onto the stack. If the copy function fn is NULL memcpy is used in its place.
References gstack::count, gstack_node::data, gstack::head, and gstack_node::next.
| void* gstack_top | ( | const struct gstack * | s | ) |
Return the address of first (most recently pushed) element in the queue.
References gstack_node::data, and gstack::head.
1.8.13