Next: , Previous: Successor, Up: Private Routines


3.2.16 Traverse

Walk a tree, processing each node.

Synopsis

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

Parameters

Tree *tree
the tree to walk
Node *node
the node to start at, must be ROOT(tree)
int (*action)(void *)
the action to perform at each node
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

Traverse 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.

Returns

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