Next: Delete, Previous: Private Routines, Up: Private Routines
Search a (sub)tree for a node with comporable data, keeping track of siblings.
#include <rbtree/rbtree.h>static Node *BndSearch( Tree *tree, Node *x, Node **prev, Node **next, const void *data, int (*cmp)(const void *,const void *) );
Tree *tree
- the tree to search
Node *x
- the node at which to start the search
Node **prev
- where to stick a pointer to the predecessor node
Node **next
- where to stick a pointer to the successor node
const void *data
- the data to search for
int (*cmp)(const void *,const void *)
- the address of a node comparison function
This routine will search a tree for the node which has data comparable to that which is passed, using the passed comparison routine. If the node does not exist, it returns the predecessor and successor nodes. the start node need not be the root of the tree, allowing for sub-tree searches.
It returns a pointer to the found node upon sucess. If no node is
found, it sets the parameters next and/or prev to point to the
successor and predecessor nodes. If those nodes don't exist, the
pointers are set to NIL(tree)
.