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