Next: , Previous: rbtree_search_node, Up: Public Routines


3.1.26 rbtree_traverse

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

Synopsis

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

Parameters

RBTree rbtree
a handle to the rbtree to traverse
int (*action)(void *nd)
the user supplied action routine applied to each node
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_traverse is substantially faster than calling rbtree_walk with an in-order visit, and uses fewer resources.

Returns

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