Next: , Previous: rbtree_search, Up: Public Routines


3.1.25 rbtree_search_node

Search a red-black tree for a node with equivalent data.

Synopsis

     #include <rbtree/rbtree.h>
     
     
     
RBNode rbtree_search_node( RBTree rbtree, const void *data, int (*cmp)(const void *,const void *) );

Parameters

RBTree rbtree
the tree to search
const void *data
the data to match
int (*cmp)(const void *,const void *)
The address of a comparison function. Set to RBTREE_NULL_CMP to use the tree's initial comparison function.

Description

This routine searches a red-black tree for the node for which the passed data compares equivalently with the node's data. It uses the passed comparison routine, if available. If not, it uses that with which the tree was initialized. Note that in the former case the passed data need not have the same form as the data stored in the node. The comparison routine is called with the passed node's data as the first argument and the tree node's data as the second argument. It must return ‘-1’, ‘0’, or ‘1’ if, respectively, the first argument is less than, equal to, or greater than the second.

Returns

It returns a handle to the matching node, or NULL if not found.