Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

OSS Library Calls (t - v) tfind(3)
NAME
tfind - Finds a node in a binary search tree
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcrtldll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycrtldll
SYNOPSIS
#include <search.h>
void *tfind(
const void *key,
void * const *rootp,
int (*compar) (const void *, const void *) );
PARAMETERS
key Points to a key that specifies the entry to be searched in the binary tree.
rootp Points to a variable that points to the root of the binary tree.
compar Specifies the name (that you supply) of a comparison function (strcmp( ), for
example). This function is called with two parameters that point to the data
undergoing comparison in the binary tree.
DESCRIPTION
The tsearch( ), tfind( ), tdelete( ), and twalk( ) functions are used to operate on binary search
trees. Comparisons are done with a compare function that you supply. The address of that sup-
plied function is passed as the compar parameter in the tsearch(), tfind( ), and tdelete( ) func-
tions. The compare function is called with two parameters that point to objects that are com-
pared during the tree search. This function returns an integer less than, equal to, or greater than 0
(zero), depending on whether the object pointed to by the first parameter is less than, equal to, or
greater than the object pointed to by the second parameter.
The tfind( ) function searches for an entry in the binary tree, returning a pointer to that entry
when a match is found. When key is not matched, tfind( ) returns a null pointer.
NOTES
Note that this function is reentrant, but care should be taken to ensure that the function supplied
as the argument to compar is also reentrant.
The comparison function does not need to compare every byte; consequently, arbitrary data can
be contained in the searched keys in addition to the values undergoing comparison.
RETURN VALUES
If a node is found, the tfind( ) function returns a pointer to it. If not, the tfind( ) function returns a
null pointer.
The tfind( ) function also returns a null pointer if rootp is a null pointer on entry.
RELATED INFORMATION
Functions: bsearch(3), hsearch(3), lsearch(3), tdelete(3), tsearch(3), twalk(3), qsort(3).
527187-017 Hewlett-Packard Company 731