TwiceAsNice
2019-02-18
|
a fifo queue that never fills. More...
Classes | |
struct | _FQ |
Functions | |
static void | chkFQ (FQ *q) |
FQ * | newFQ (int grow) |
void | delFQ (FQ *q) |
void | pushFQ (FQ *q, void *e) |
void * | popFQ (FQ *q) |
void * | peekFQ (FQ *q) |
void * | peekiFQ (FQ *q, int i) |
int | nFQ (FQ *q) |
void | setMemFuncsFQ (void *(*newmalloc)(size_t size), void *(*newrealloc)(void *ptr, size_t size), void(*newfree)(void *ptr)) |
Variables | |
static void *(* | fqmalloc )(size_t size) = malloc |
static void *(* | fqrealloc )(void *ptr, size_t size) = realloc |
static void(* | fqfree )(void *ptr) = free |
a fifo queue that never fills.
Generic FIFO Queue.
an FQ is a FIFO list of pointers to void, each called an "element". elements are added at q[head]. there are (nq) elements in the list. the element to be removed next is q[head-nq]. there are (head-nq) empty slots at the front of the q array. there are (nmem-head) elements available at the end. if the head reaches the end, existing enties are slid to the front of the array and total memory is adjusted up or down as required.
example:
<-----------------— nmem = 17 ------------------------------—>
0 1 2 3 4 5 6 7 8 9 ^ head = 10
|
static |
void delFQ | ( | FQ * | q | ) |
FQ* newFQ | ( | int | grow | ) |
int nFQ | ( | FQ * | q | ) |
void* peekFQ | ( | FQ * | q | ) |
void* peekiFQ | ( | FQ * | q, |
int | i | ||
) |
void* popFQ | ( | FQ * | q | ) |
void pushFQ | ( | FQ * | q, |
void * | e | ||
) |
void setMemFuncsFQ | ( | void *(*)(size_t size) | newmalloc, |
void *(*)(void *ptr, size_t size) | newrealloc, | ||
void(*)(void *ptr) | newfree | ||
) |
|
static |
|
static |
|
static |