Next: , Previous: RightRotate, Up: Private Routines


3.2.14 Search

Search a tree for a node with comparable data.

Synopsis

     #include <rbtree/rbtree.h>
     
     
     
static Node *Search( Tree *tree, Node *x, const void *data, int (*cmp)(const void *,const void *) );

Parameters

Tree *tree
the tree to search
Node *x
the node at which to start
const void *data
the data to search for
int (*cmp)(const void *,const void *)
the address of a node comparison routine

Description

This routine will search a tree for the node which has data comparable to that passed, using the passed comparison routine. The start node need not be the root of the tree, allowing for subtree searches.

Returns

It returns the node which matches, else NIL(tree).