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.
◆ GQUEUE_DECL
#define GQUEUE_DECL |
( |
|
PREFIX, |
|
|
|
TYPE |
|
) |
| |
Value:extern int PREFIX##_push(
struct gqueue* q, TYPE
const* data); \
extern TYPE* PREFIX##_top(
struct gqueue* q); \
extern
void PREFIX##_pop(
struct gqueue* q);
Declare specialized gqueue
functions.
◆ GQUEUE_DEFN
#define GQUEUE_DEFN |
( |
|
PREFIX, |
|
|
|
TYPE, |
|
|
|
COPY, |
|
|
|
FREE |
|
) |
| |
Value:
GQUEUE_TOP_DEFN(PREFIX,TYPE) \
GQUEUE_POP_DEFN(PREFIX,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.
◆ GQUEUE_POP_DEFN
#define GQUEUE_POP_DEFN |
( |
|
PREFIX, |
|
|
|
FREE |
|
) |
| |
Value:void PREFIX##_pop(
struct gqueue* q) { \
}
Define a specialized gqueue
pop function.
◆ GQUEUE_PUSH_DEFN
#define GQUEUE_PUSH_DEFN |
( |
|
PREFIX, |
|
|
|
TYPE, |
|
|
|
COPY |
|
) |
| |
Value:int PREFIX##_push(
struct gqueue* q, TYPE
const* data) { \
}
Define a specialized gqueue
push function.
◆ GQUEUE_TOP_DEFN
#define GQUEUE_TOP_DEFN |
( |
|
PREFIX, |
|
|
|
TYPE |
|
) |
| |
Value:TYPE* PREFIX##_top(
struct gqueue* q) { \
}
Define a specialized gqueue
top function.
◆ gqueue_pop()
◆ gqueue_push()
int gqueue_push |
( |
struct gqueue * |
q, |
|
|
unsigned |
datasize, |
|
|
const void * |
data, |
|
|
adt_copy_fn * |
fn |
|
) |
| |
◆ gqueue_top()
void* gqueue_top |
( |
const struct gqueue * |
q | ) |
|
int gqueue_push(struct gqueue *d, unsigned datasize, const void *data, adt_copy_fn *fn)
Definition: gqueue_push.c:8