Next: , Previous: rbtree_traverse, Up: Public Routines


3.1.27 rbtree_utraverse

Traverse a red-black binary tree in order, processing each node.

Synopsis

     #include <rbtree/rbtree.h>
     
     
     
int rbtree_utraverse( RBTree rbtree, int (*action)(void *nd,void *udata), void *udata, SiblingOrder sibling_order );

Parameters

RBTree rbtree
a handle to the rbtree to traverse
int (*action)(void *nd,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

Description

This routine walks along an rbtree, calling a user supplied action function at the in-order traversals of each node. The tree traversal is aborted if the action routine returns non-zero. rbtree_utraverse is substantially faster than calling rbtree_uwalk with an in-order visit, and uses fewer resources. This routine differs from rbtree_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.