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

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

CLList



typedef LListElement CLListElement;

typedef struct _CLList{
    int size;
    CLListElement *head;
    destroyfunc* destroy;
    comparefunc* cmp;
} CLList;


    The CLList data structure represents a circular singly-linked list. 

Related functions and macros



CLList* cllist_create(destroyfunc* destroy, comparefunc* cmp);

description: creates a new, empty circular singly-linked list. The destroy parameter is a pointer to a destroyfunc . This function is called to free dynammically allocated data when cllist_destroy is called. If the list contains data that should not be freed, it should be set to NULL. The cmp parameter is a pointer to a comparefunc . This function is used by the CLList data structure to compare it's elements when cllist_element_is_member is called. This parameter should be set to NULL if cllist_element_is_member won't be necessary.

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

since: YACLib 1.0

int cllist_insert_next(CLList* cllist, CLListElement* prev, const void* data)

description: inserts an element in the circular singly-linked list specified by cllist, after the element prev.  The new element stores a pointer to data.

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

since: YACLib 1.0

int cllist_remove_next(CLList* cllist, CLListElement* prev, void** data)

description: removes an element from the circular singly-linked list specified by cllist, after the element prev.  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

void cllist_remove_all(CLList* cllist)

description: removes all the elements from  the circular singly-linked list specified by cllist.

return value:
none.

since: YACLib 1.0
int cllist_element_is_member(const CLList* cllist,const void* data)

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

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

since: YACLib 1.0
void cllist_destroy(CLList* cllist)

description:  destroys the circular singly-linked list specified by cllist. It removes all the elements from the list and calls the destroyfunc function passed  to cllist_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 cllist_size(const CLList* cllist)

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

return value: the number of elements in cllist.

since: YACLib 1.0
CLListElement* cllist_head(const CLList* cllist)

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

return value:  the head of cllist.

since: YACLib 1.0

CLListElement* cllist_tail(const CLList* cllist)

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

return value the tail of cllist.

since: YACLib 1.0
CLListElement* cllist_element_next(const CLListElement* element)

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

return value the next pointer of element.

since: YACLib 1.0

void* cllist_element_data(const CLListElement* element)

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

return value the data pointer of element.

since: YACLib 1.0