Next: , Previous: Traverse, Up: Private Routines


3.2.17 uTraverse

Walk a tree, processing each node.

Synopsis

     #include <rbtree/rbtree.h>
     
     
     
static int uTraverse( Tree *tree, Node *node, int (*action)(void *,void *udata), void *udata, SiblingOrder sibling_order );

Parameters

Tree *tree
the tree to walk
Node *node
the node to start at, must be ROOT(tree)
int (*action)(void *,void *udata)
the action to perform at each node
void *udata
a pointer to data to be passed to the action routine
SiblingOrder sibling_order
the order in which to traverse the tree
          
          
Possible values for a SiblingOrder are as follows: LEFT_TO_RIGHT, RIGHT_TO_LEFT

Description

uTraverse quickly walks a tree in a prescribed order, performing a user supplied action on each node, in-order. If the action function returns non-zero, the walk is aborted. This routine differs from Traverse in that it can pass along a pointer provided by the calling routine to the action routine, allowing arbitrary data to be available to the action routine.

Returns

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