Main Page | Directories | File List | File Members

ll.h File Reference

Go to the source code of this file.

Defines

#define LL_H   1

Typedefs

typedef elem_s elem_t
 Linked list element.
typedef list_s list_t
 Linked list.
typedef void elem_destroy_cb (void *data)
 Callback prototype for destroying element data.

Functions

list_tlist_new (elem_destroy_cb *cb)
 Creates a new linked list.
void list_destroy (list_t *list)
 Free all resources associated with the given linked list.
void list_flush (list_t *list)
 Remove all elements from the list without destroying the list itself.
void * element_data (elem_t *elem)
 Retrieves the data associated with a list element.
elem_tlist_append (list_t *list, void *data)
 Append a new element to the end of the list.
int list_size (list_t *list)
 Returns the number of elements in the list.
elem_tlist_get (list_t *list, int idx)
 Returns the list element at the specified index or NULL if the index is invalid.
elem_tlist_first (list_t *list)
 Returns the first list element.
elem_tlist_next (list_t *list)
 Returns the next list element.


Define Documentation

#define LL_H   1
 


Typedef Documentation

typedef void elem_destroy_cb(void *data)
 

Callback prototype for destroying element data.

typedef struct elem_s elem_t
 

Linked list element.

typedef struct list_s list_t
 

Linked list.


Function Documentation

void* element_data elem_t elem  ) 
 

Retrieves the data associated with a list element.

Parameters:
elem The list element.
Returns:
The data associated with the element or NULL if the element was invalid.

elem_t* list_append list_t list,
void *  data
 

Append a new element to the end of the list.

Parameters:
list The linked list.
data The data to append to the list.
Returns:
The list element that was appended or NULL if memory allocation fails or the list is invalid.

void list_destroy list_t list  ) 
 

Free all resources associated with the given linked list.

Embedded data will be freed by use of the callback registered at list creation.

Parameters:
list The linked list.

elem_t* list_first list_t list  ) 
 

Returns the first list element.

Parameters:
list The linked list.
Returns:
The first element or NULL if the list is empty.

void list_flush list_t list  ) 
 

Remove all elements from the list without destroying the list itself.

Embedded data will be freed by use of the callback registered at list creation.

Parameters:
list The linked list.

elem_t* list_get list_t list,
int  idx
 

Returns the list element at the specified index or NULL if the index is invalid.

Parameters:
list The linked list.
idx The element index (first = 0).
Returns:
The element or NULL if not found.

list_t* list_new elem_destroy_cb cb  ) 
 

Creates a new linked list.

Parameters:
cb The callback used to destroy the element data or NULL if no further action is required.
Returns:
The linked list structure or NULL if memory allocation failed.

elem_t* list_next list_t list  ) 
 

Returns the next list element.

Before using this function you should call list_first to initialize the iterator.

Parameters:
list The linked list.
Returns:
The next element or NULL if not found.

int list_size list_t list  ) 
 

Returns the number of elements in the list.

Parameters:
list The linked list.
Returns:
The number of elements.


Generated on Sat Jul 9 11:18:31 2005 for libcddb by  doxygen 1.3.9.1