Next: , Previous: dll_tail_node, Up: Doubly Linked Lists


3.2.32 dll_traverse

Traverse a doubly linked list either forwards or backwards, processing each node.

Synopsis

     #include <linklist/linklist.h>
     
     
     
int dll_traverse( DLinkList ull, int (*action)(void *), LinkTraverseDirection direction );

Parameters

DLinkList ull
A handle to the list to traverse
int (*action)(void *)
The user supplied action routine applied to each node
LinkTraverseDirection direction
the direction in which to traverse the list
          
          
Possible values for a LinkTraverseDirection are as follows: HEAD_TO_TAIL, TAIL_TO_HEAD

Description

This routine walks along a list, calling a user supplied action function at each node.The action routine is passed the node's data pointer. If an invocation of the action routine returns non-zero, the traversal is aborted and the action routine's return value is returned.

Compare this to dll_traverse_d, dll_utraverse, and dll_utraverse_d.

Returns

If the action routines all return ‘0’, it returns ‘0’, else it returns the value returned by the last action routine called.