typedef LListElement QueueElement; typedef LList Queue; The Queue data structure represents a queue and it is a front-end to the LList data structure. |
| Queue* queue_create(destroyfunc*
destroy, comparefunc* cmp) description: creates a new, empty queue. The destroy parameter is a pointer to a user-defined destroyfunc. This function will be used by queue_destroy to free dynamically allocated data. If the data to be inserted in the 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 queue_element_is_member function to compare the queue elements. If queue_element_is_member won't be necessary, cmp should be set to NULL. return value: a pointer to a new Queue data structure, or NULL if the allocation fails. since: YACLib 1.0 int queue_enqueue(Queue* queue, const void* data) description: enqueues an element into the queue specified by queue. The new element will store a pointer to data. return value: 0 if the element could be enqueued, -1 otherwise. since: YACLib 1.0 int queue_dequeue(Queue* queue, void** data) description: dequeue an element from the queue specified by queue. 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.0 void queue_remove_all(Queue* queue) description: removes all elements from the queue specified by queue. return value: none. since: YACLib 1.0 int queue_element_is_member(const Queue* queue, const void* data) description: searches for an element matching data in the queue specified by queue. return value: 1 if an element matching data was found, 0 othrewise. since: YACLib 1.0 void queue_destroy(Queue* queue) description: destroys the queue specified by queue. It will remove all the elements from the queue and call the destroyfunc function passed to queue_create for each element as it is removed from the queue, provided destroy wasn't set to NULL. return value: none. since: YACLib 1.0 QueueElement* queue_first(const Queue* queue) description: macro that evaluates to the first element of the queue specified by queue. return value: the first element of queue. since: YACLib 1.0 QueueElement* queue_last(const Queue* queue) description: macro that evaluates to the last element of the queue specified by queue. return value: the last element of queue. since: YACLib 1.0 int queue_size(const Queue* queue) description: macro that evaluates to the number of elements in the queue specified by queue. return value: the number of elements in queue. since: YACLib 1.0 QueueElement* queue_element_next(const QueueElement* element) description: macro that evaluates to the next pointer of the queue element specified by element. return value: the next pointer of element. since: YACLib 1.1 void* queue_element_data(const QueueElement* element) description: macro that evaluates to the data pointer of the queue element specified by element. return value: the data pointer of element. since: YACLib 1.1 |