Next: rbtree_utraverse, Previous: rbtree_search_node, Up: Public Routines
Traverse a red-black binary tree in order, processing each node.
#include <rbtree/rbtree.h>int rbtree_traverse( RBTree rbtree, int (*action)(void *nd), SiblingOrder sibling_order );
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 aSiblingOrder
are as follows:LEFT_TO_RIGHT
,RIGHT_TO_LEFT
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.
If the action routines all return `0', it returns `0', else it returns the value returned by the last action routine called.