Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

Single Linked List
[SB Library]

Link list handling for hash map. More...

Data Structures

struct  ListElmt_
 Define a structure for linked list elements. More...
struct  List_
 Define a structure for linked lists. More...

Defines

#define list_size(list)   ((list)->size)
 get list size
#define list_head(list)   ((list)->head)
 get first element
#define list_tail(list)   ((list)->tail)
 get last element
#define list_is_head(list, element)   ((element) == (list)->head ? 1 : 0)
 is it head of list
#define list_is_tail(element)   ((element)->next == NULL ? 1 : 0)
 is it tail of list
#define list_data(element)   ((element)->data)
 get data of element
#define list_next(element)   ((element)->next)
 get next element

Typedefs

typedef ListElmt_ ListElmt
 Define a structure for linked list elements.
typedef List_ List
 Define a structure for linked lists.

Functions

void list_init (List *list, int(*match)(const void *key1, const void *key2), void(*destroy)(void *data))
 Initialize link list.
void list_destroy (List *list)
 Destroy link list.
int list_getsize (List *list)
 Get number of elements in list.
int list_insert (List *list, void *data)
 Insert element in link list.
int list_lookup (List *list, void **data)
 Lookup for element in link list.
int list_foreach_match (List *list, int(*matchfunc)(const void *key1, const void *key2), void(*cbfunc)(const void *data), void **data)
 Lookup for element in link list and call function for each match.
int list_for_each_call (List *list, int(*func)(void *data, void *userdata), void *userdata)
 Iterate over each element of link list and call function.
int list_remove_each_if_func_eq_1 (List *list, int(*func)(void *data, void *userdata), void *userdata)
 Remove each element from link list, where function returns 1.
int list_remove (List *list, void **data)
 Remove element from link list.
int list_ins_next (List *list, ListElmt *element, const void *data)
 Insert element in link list.
int list_rem_next (List *list, ListElmt *element, void **data)
 Remove element from link list.
int stringMatchFunction (const void *key1, const void *key2)
 Simple match function for strings.
void stringFreeFunction (void *ptr)
 Simple free function for strings.
int list_internal_lookup (List *list, void **data)
 Lookup for element in link list.

Detailed Description

Link list handling for hash map.

Author:
Stefan Bambach (sbambach@gmx.net)
Version:
0.1

Function Documentation

void list_destroy List list  ) 
 

Destroy link list.

Parameters:
list Pointer to List struct
Returns:
0 if successfully removed, -1 otherwise.

Definition at line 39 of file linklist.c.

References List_::destroy, List, list_rem_next(), list_size, List_::rwlock, T_RDWR_WLOCK, and T_RDWR_WUNLOCK.

Referenced by chtbl_destroy().

int list_for_each_call List list,
int(*)(void *data, void *userdata)  func,
void *  userdata
 

Iterate over each element of link list and call function.

Parameters:
list Pointer to List struct
func This function is called for each element in list
userdata This is an argument for the callback function
Returns:
0 if successfully called function for all elements, -1 otherwise.

Definition at line 125 of file linklist.c.

References ListElmt_::data, List, list_head, list_next, ListElmt, List_::rwlock, T_RDWR_RLOCK, and T_RDWR_RUNLOCK.

int list_foreach_match List list,
int(*)(const void *key1, const void *key2)  matchfunc,
void(*)(const void *data)  cbfunc,
void **  data
 

Lookup for element in link list and call function for each match.

Parameters:
list Pointer to List struct
matchfunc Pointer to callback-function that will decide, if cbfunc will be called
cbfunc Pointer to callback-function
data Pointer to pointer to data to be searched
Returns:
0 if successfully removed, -1 otherwise.

Definition at line 184 of file linklist.c.

References List, list_data, list_head, list_next, ListElmt, List_::rwlock, T_RDWR_RLOCK, and T_RDWR_RUNLOCK.

int list_getsize List list  ) 
 

Get number of elements in list.

Parameters:
list Pointer to List struct
Returns:
Number of elements in link list

Definition at line 66 of file linklist.c.

References List, list_size, List_::rwlock, T_RDWR_RLOCK, and T_RDWR_RUNLOCK.

Referenced by chtbl_size().

void list_init List list,
int(*)(const void *key1, const void *key2)  match,
void(*)(void *data)  destroy
 

Initialize link list.

Parameters:
list Pointer to List struct
match Match function
destroy Destroy function
Returns:
0 if successfully removed, -1 otherwise.

Definition at line 11 of file linklist.c.

References List_::destroy, List_::head, List, List_::match, List_::rwlock, List_::size, T_RDWR_INIT, and List_::tail.

Referenced by chtbl_init().

int list_insert List list,
void *  data
 

Insert element in link list.

Parameters:
list Pointer to List struct
data Pointer to data to be removed
Returns:
0 if successfully inserted, -1 otherwise.

Definition at line 83 of file linklist.c.

References List, list_ins_next(), list_internal_lookup(), List_::rwlock, T_RDWR_WLOCK, and T_RDWR_WUNLOCK.

Referenced by chtbl_insert().

int list_lookup List list,
void **  data
 

Lookup for element in link list.

Parameters:
list Pointer to List struct
data Pointer to pointer to data to be searched
Returns:
0 if successfully removed, -1 otherwise.

Definition at line 108 of file linklist.c.

References List, list_internal_lookup(), List_::rwlock, T_RDWR_RLOCK, and T_RDWR_RUNLOCK.

Referenced by chtbl_lookup().

int list_remove List list,
void **  data
 

Remove element from link list.

Parameters:
list Pointer to List struct
data Pointer to pointer to data to be removed
Returns:
0 if successfully removed, -1 otherwise.

Definition at line 208 of file linklist.c.

References List, list_data, list_head, list_next, list_rem_next(), ListElmt, List_::match, List_::rwlock, T_RDWR_WLOCK, and T_RDWR_WUNLOCK.

Referenced by chtbl_remove().

int list_remove_each_if_func_eq_1 List list,
int(*)(void *data, void *userdata)  func,
void *  userdata
 

Remove each element from link list, where function returns 1.

Parameters:
list Pointer to List struct
func This function is called for each element in list
userdata This is an argument for the callback function
Returns:
0 if successfully called function for all elements, -1 otherwise.

Definition at line 150 of file linklist.c.

References List_::destroy, List, list_data, list_head, list_next, list_rem_next(), ListElmt, List_::rwlock, T_RDWR_WLOCK, and T_RDWR_WUNLOCK.


Generated on Wed Mar 30 13:43:27 2005 for Mntd by  doxygen 1.3.9.1