| #define ODLLIST_CRESCENT
1 #define ODLLIST_DECRESCENT -1 typedef DLListElement ODLListElement; typedef struct _ODLList{ int size; ODLListElement *head,*tail; destroyfunc* destroy; comparefunc* cmp; int order; } ODLList; The ODLList data structure represents an ordered doubly-linked list. |
| ODLList* odllist_create(destroyfunc*
destroy, comparefunc* cmp, int order); description: creates a new, empty ordered doubly-linked list. The destroy parameter is a pointer to a destroyfunc . This function is called to free dynammically allocated data when odllist_destroy is called. If the list contains data that should not be freed, it should be set to NULL. The cmp parameter is a valid pointer to a comparefunc . This function is used by the ODLList data structure to compare it's elements. The order parameter is an integer value indicating the order that the list will store it's elements. There are two possible values to this parameter: ODLLIST_CRESCENT for the list to store it's elements in crescent order, and ODLLIST_DECRESCENT for the list to store it's elements in decrescent order. return value: a pointer to a new ODLList data structure or NULL if the allocation fails. since: YACLib 1.0 int odllist_insert(ODLList* odllist, const void* data) description: inserts an element in the ordered doubly-linked list specified by odllist. The new element stores a pointer to data. return value: 0 if the element could be inserted, -1 otherwise. since: YACLib 1.0 int odllist_remove(ODLList* odllist,ODLListElement* element,void** data) description: removes the element element from the ordered doubly-linked list specified by odllist. Upon return, data points to the data stored in the element that was removed. return value: 0 if the element could be removed, -1 otherwise. since: YACLib 1.0 int odllist_remove_at(ODLList* odllist, int pos, void** data) description: removes an element from the ordered doubly-linked list specified by odllist, at the position specified by pos. pos must be a positive integer different than zero. If pos is greater than (or equal to) the list's size, then the element will be removed from the tail of the list. Upon return, data points to the data stored in the element that was removed. return value: 0 if the element could be removed, -1 otherwise. since: YACLib 1.0 int odllist_remove_first(ODLList* odllist, void** data) description: removes the first element from the ordered doubly-linked list specified by odllist. Upon return, data points to the data stored in the element that was removed. return value: 0 if the element could be removed, -1 otherwise. since: YACLib 1.1 int odllist_remove_last(ODLList* odllist, void** data) description: removes the last element from the ordered doubly-linked list specified by odllist. Upon return, data points to the data stored in the element that was removed. return value: 0 if the element could be removed, -1 otherwise. since: YACLib 1.1 int odllist_remove_all(ODLList* odllist) description: removes all elements from the ordered doubly-linked list specified by odllist. return value: 0 if the elements could be removed, -1 otherwise. since: YACLib 1.0 int odllist_element_is_member(const ODLList* odllist,const void* data) description: searches for an element matching data in the ordered doubly-linked list specified by odllist. return value: 1 if an element matching data was found, 0 otherwise. since: YACLib 1.0 void odllist_destroy(ODLList* odllist) description: destroys the ordered doubly-linked list specified by odllist. It removes all the elements of the list and calls the destroyfunc function passed to odllist_create for each element as it is removed from the list, provided destroy wasn't set to NULL. return value: none since: YACLib 1.0 int odllist_size(const ODLList* odllist) description: macro that evaluates to the number of elements in the ordered doubly-linked list specified by odllist. return value: the number of elements in odllist. since: YACLib 1.0 ODLListElement* odllist_head(const ODLList* odllist) description: macro that evaluates to the head of the ordered doubly-linked list specified by odllist. return value: a pointer to the head of odllist. since: YACLib 1.0 ODLListElement* odllist_tail(const ODLList* odllist) description: macro that evaluates to the tail of the ordered doubly-linked list specified by odllist. return value: the tail of odllist. since: YACLib 1.0 ODLListElement* odllist_element_next(const ODLListElement* element) description: macro that evaluates to the next pointer of the ordered doubly-linked list element specified by element. return value: the next pointer of element. since: YACLib 1.0 ODLListElement* odllist_element_prev(const ODLListElement* element) description: macro that evaluates to the prev pointer of the ordered doubly-linked list element specified by element. return value: the prev pointer of element. since: YACLib 1.0 void* odllist_element_data(const ODLListElement* element) description: macro that evaluates to the data pointer of the ordered doubly-linked list element specified by element. return value: the data pointer of element. since: YACLib 1.0 |