Previous: rbtree_walk, Up: Public Routines


3.1.29 rbtree_uwalk

Walk along a tree, processing each node.

Synopsis

     #include <rbtree/rbtree.h>
     
     
     
int rbtree_uwalk( RBTree rbtree, int (*action)(void *nd,Visit visit,unsigned long level,void *udata), void *udata, SiblingOrder sibling_order, Visit visit );

Parameters

RBTree rbtree
a handle to the rbtree to traverse
int (*action)(void *nd,Visit visit,unsigned long level,void *udata)
the user supplied action routine applied to each node
void *udata
a pointer to data to be passed to the action routine
SiblingOrder sibling_order
the direction in which the tree is traversed
          
          
Possible values for a SiblingOrder are as follows: LEFT_TO_RIGHT, RIGHT_TO_LEFT
Visit visit
The node traversals at which to call the action routine. The logical or of possible Visit values.
          
          
Possible values for a Visit are as follows: PRE_ORDER, IN_ORDER, POST_ORDER

Description

This routine traverses an rbtree, calling a user supplied action function at selectable traversals of each node (any combination of pre-order, in-order, or post-order). The function is informed of which node traversal and which tree level it is called from. The walk is aborted if the action routine returns non-zero. This routine differs from rbtree_walk 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.

The traversals at which the action routine is called at are specified by the logical or of PRE_ORDER, IN_ORDER, or POST_ORDER.

Returns

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