tfind()

search for node in binary tree 

Function


SYNOPSIS

#include <search.h>

void *tfind(void *key, void **rootp, int(*compar) (const void *, const void *));


DESCRIPTION

Like tsearch(), tfind() searches for a node in a binary search tree, returning a pointer to it if found. key is a pointer to the node to find. rootp is the root of the tree to be traversed. If there is a node in the tree equal to *key, a pointer to this node is returned. Otherwise, tfind() returns a null pointer.

All comparisons are done with a user-supplied routine, compar. This routine is called with two arguments, the pointers to the elements being compared. It returns an integer less than, equal to, or greater than 0, according to whether the first argument is to be considered less than, equal to, or greater than the second argument. The comparison function need not compare every byte, so arbitrary data may be contained in the elements in addition to the values being compared.

If the calling function alters rootp, results are unpredictable.


PARAMETERS

key 

Points to the node to find.

rootp 

Points to a pointer to the root of the tree. A null value for the variable pointed to by rootp denotes an empty tree.

compar 

Is the comparator function.


RETURN VALUES

tfind() returns a pointer to the node, if found, and a null pointer otherwise.


CONFORMANCE

UNIX 98.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
bsearch(), hsearch(), tdelete(), tsearch(), twalk()


MKS Toolkit 9.2 Documentation Build 16.