Next: Walk, Previous: Traverse, Up: Private Routines
Walk a tree, processing each node.
#include <rbtree/rbtree.h>static int uTraverse( Tree *tree, Node *node, int (*action)(void *,void *udata), void *udata, SiblingOrder sibling_order );
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 aSiblingOrder
are as follows:LEFT_TO_RIGHT
,RIGHT_TO_LEFT
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.
If the action routines all return ‘0’, it returns ‘0’, else it returns the value returned by the last action routine called.