Simple C Expat Wrapper (SCEW)  1.1.7
Files | Functions
Traverse

Traverse list items. More...

Files

file  list.h
 SCEW general list implementation.
 

Functions

SCEW_API scew_listscew_list_first (scew_list *list)
 Finds the first item of the given list. More...
 
SCEW_API scew_listscew_list_last (scew_list *list)
 Finds the last item of the given list. More...
 
SCEW_API scew_listscew_list_next (scew_list *list)
 Obtains the next item of the given list item. More...
 
SCEW_API scew_listscew_list_previous (scew_list *list)
 Obtains the previous item of the given list item. More...
 
SCEW_API void scew_list_foreach (scew_list *list, scew_list_hook hook, void *user_data)
 Traverses all list items and executes the given hook for each item found. More...
 

Detailed Description

Traverse list items.

Function Documentation

SCEW_API scew_list* scew_list_first ( scew_list list)

Finds the first item of the given list.

This function traverses all the list backwards until it finds an item whose previous item is NULL.

Precondition
list != NULL
Returns
the first item of the given list or NULL if list is NULL.
SCEW_API scew_list* scew_list_last ( scew_list list)

Finds the last item of the given list.

This function traverses all the list forwards until it finds an item whose next item is NULL.

Precondition
list != NULL
Returns
the last item of the given list or NULL if list is NULL.
SCEW_API scew_list* scew_list_next ( scew_list list)

Obtains the next item of the given list item.

Precondition
list != NULL
Returns
the next list item or NULL if list is the last item.
SCEW_API scew_list* scew_list_previous ( scew_list list)

Obtains the previous item of the given list item.

Precondition
list != NULL
Returns
the previous list item or NULL if list is the first item.
SCEW_API void scew_list_foreach ( scew_list list,
scew_list_hook  hook,
void *  user_data 
)

Traverses all list items and executes the given hook for each item found.

The hook takes an extra paramter, user_data, which might be NULL.

Precondition
list != NULL
func != NULL
Parameters
listthe list to traverse.
hookthe action to be executed for every traversed item.
user_dataan optional user data pointer (might be NULL).