Site hosted by Angelfire.com: Build your free website today!

(c) 2002 - Pedro Flynn <pflynn@microsoftsucks.org>

OLList

#define OLLIST_CRESCENT            1
#define OLLIST_DECRESCENT     -1

typedef LListElement OLListElement;

typedef struct _OLList{
    int size;
    OLListElement *head,*tail;
    destroyfunc* destroy;
    comparefunc* cmp;
    int order;
} OLList;


    The OLList data structure represents an ordered singly-linked list. 

Related functions and macros



OLList* ollist_create(destroyfunc* destroy, comparefunc* cmp, int order);

description: creates a new, empty ordered singly-linked list.The destroy parameteris a pointer to a destroyfunc. This function is called to free dynammically allocated data when ollist_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 OLList 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: OLLIST_CRESCENT for the list to store it's elements in a crescent order, and OLLIST_DECRESCENT for the list to store it's elements in a decrescent order.

return value:
a pointer to a  new OLList data structure or NULL if the allocation fails.

since: YACLib 1.0

int ollist_insert(OLList* ollist, const void* data)

description: inserts an element in the ordered singly-linked list specified by ollist. The new element stores a pointer to data. 

return value:
0 if the element could be inserted, -1 otherwise.

since: YACLib 1.0

int ollist_remove_next(OLList* ollist, OLListElement* element, void** data)

description: removes an element from the ordered singly-linked list specified by ollist, after the element prev. If prev is NULL, the element will be removed from the head 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 ollist_remove_at(OLList* ollist, int pos, void** data)

description: removes an element from the ordered singly-linked list specified by ollist, 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 ollist_remove_first(OLList* ollist, void** data)

description: removes the first element from the ordered singly-linked list specified by ollist.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 ollist_remove_all(OLList* ollist)

description: removes all elements from the ordered singly-linked list specified by ollist.

return value:
0 if the elements could be removed, -1 otherwise.

since: YACLib 1.0

int ollist_element_is_member(const OLList* ollist, const void* data)

description: searches for an element matching data in the ordered singly-linked list specified by ollist.

returns:
1 if  an element matching  data was found, 0 otherwise.

since: YACLib 1.0

int ollist_get_previous(const OLList* ollist, const void* elementdata, OLListElement** prevptr)

description: get a pointer to the element previous to the element matching elementdata, in the ordered singly-linked list specified by ollist. Upon return, this pointer is assigned to prevptr.

return value:
0 if  an element matching data was found, -1 otherwise.

since: YACLib 1.0

void ollist_destroy(OLList* ollist)

description:  destroys the ordered singly-linked list specified by ollist. It removes all the elements of the list and calls the destroyfunc function passed to ollist_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  ollist_size(const OLList* ollist)

description:  macro that evaluates to the number of elements in the ordered singly-linked list specified by ollist.

return value: the number of elements in ollist.

since: YACLib 1.0

OLListElement* ollist_head(const OLList* ollist)

description:  macro that evaluates to the head of the ordered singly-linked list specified by ollist.

return value: the head of ollist.

since: YACLib 1.0

OLListElement* ollist_tail(const OLList* ollist)

description:  macro that evaluates to the tail of the ordered singly-linked list specified by ollist.

return value: the tail of ollist.

since: YACLib 1.0
OLListElement* ollist_element_next(const OLListElement* element)

description:  macro that evaluates to the next pointer of  the  ordered singly-linked list element specified by element.

return value: the next pointer of element.

since: YACLib 1.0

void* ollist_element_data(const OLListElement* element)

description:  macro that evaluates to the data pointer of  the ordered singly-linked list element specified by element.

return value: the data pointer of element.

since: YACLib 1.0