typedef LListElement CQueueElement; typedef struct _CQueue { int size; CQueueElement* last; destroyfunc* destroy; comparefunc* cmp; }CQueue; The CQueue data structure represents a circular queue. |
| CQueue* cqueue_create(destroyfunc*
destroy, comparefunc* cmp) description: creates a new, empty circular queue. The destroy parameter is a pointer to a user-defined destroyfunc. This function will be used by cqueue_destroy to free dynamically allocated data. If the data to be inserted in the circular queue should not be freed, destroy should be set to NULL. The cmp parameter is a pointer to a user-defined comparefunc. This function will be used by the cqueue_element_is_member function to compare the circular queue elements. If cqueue_element_is_member won't be necessary, cmp should be set to NULL. return value: a pointer to a new CQueue data structure, or NULL if the allocation fails. since: YACLib 1.1 int cqueue_enqueue(CQueue* cqueue, const void* data) description: enqueues an element into the circular queue specified by cqueue. The new element will store a pointer to data. return value: 0 if the element could be enqueued, -1 otherwise. since: YACLib 1.1 int cqueue_dequeue(CQueue* cqueue, void** data) description: dequeues an element from the circular queue specified by cqueue. Upon return, data points to the data stored in the element that was dequeued. return value: 0 if the element could be dequeued, -1 otherwise. since: YACLib 1.1 void cqueue_dequeue_all(CQueue* cqueue) description: dequeues all elements from the circular queue specified by cqueue. return value: none. since: YACLib 1.1 int cqueue_element_is_member(const CQueue* cqueue, const void* data) description: searches for an element matching data in the circular queue specified by cqueue. return value: 1 if an element matching data was found, 0 othrewise. since: YACLib 1.1 void cqueue_destroy(CQueue* cqueue) description: destroys the circular queue specified by cqueue. It will remove all the elements from the circular queue and call the destroyfunc function passed to cqueue_create for each element as it is removed from the circular queue, provided destroy wasn't set to NULL. return value: none. since: YACLib 1.1 CQueueElement* cqueue_first(const CQueue* cqueue) description: macro that evaluates to the first element of the circular queue specified by cqueue. return value: the first element of cqueue. since: YACLib 1.1 CQueueElement* cqueue_last(const CQueue* cqueue) description: macro that evaluates to the last element of the circular queue specified by cqueue. return value: the last element of cqueue. since: YACLib 1.1 int cqueue_size(const CQueue* cqueue) description: macro that evaluates to the number of elements in the circular queue specified by cqueue. return value: the number of elements in cqueue. since: YACLib 1.1 CQueueElement* cqueue_element_next(const CQueueElement* element) description: macro that evaluates to the next pointer of the circular queue element specified by element. return value: the the next pointer of element. since: YACLib 1.1 void* cqueue_element_data(const CQueueElement* element) description: macro that evaluates to the data pointer of the circular queue element specified by element. return value: the the data pointer of element. since: YACLib 1.1 |