This data structure is based on circular buffer, and can be used both like a FIFO and a Stack.
Following functions are available for use in C:
typedef ... CdsFifo;
An opaque data type representing a queue of void* pointers.
CdsFifo CdsFifo_Create(void);
Creates a queue in memory and returns its pointer.
CdsFifo CdsFifo_Create_len(int len);
Creates a queue in memory with the initial buffer size of len entries
and returns its pointer.
void CdsFifo_Enqueue(CdsFifo q, void *elt);
Appends elt at the end of q.
void *CdsFifo_Dequeue(CdsFifo q);
Removes an element from the front of the q, and returns it. Returns
0 if the queue is empty.
void *CdsFifo_Pop(CdsFifo q);
Removes an element from the front of the q, and returns it. Returns
0 if the queue is empty. An alias for the dequeue function.
void CdsFifo_Push(CdsFifo q, void *elt);
Inserts elt in the beginning of q.
int CdsFifo_Empty(CdsFifo q);
Returns 1 if the q is empty, 0 otherwise.
int CdsFifo_Length(CdsFifo q);
Returns the length of the q.
int CdsFifo_Peek(CdsFifo q);
Returns the element from the front of the q without removing it.
void CdsFifo_Destroy(CdsFifo q);
Releases memory used by q.
Following Templates are available for use in C++:
November 23, 2009
Charm Homepage