Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)

Guardian Native C Library Calls (t - z) tdelete(3)
NAME
tdelete - Deletes a node from a binary search tree
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <search.h>
void *tdelete(
const void *key,
void **rootp,
int (*compar) (const void *, const void *) );
PARAMETERS
key Points to a key that species the entry to be searched in the binary tree.
rootp Points to a variable that points to the root of the binary tree.
compar Species 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(), tnd(), 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(), tnd(), and tdelete() func-
tions.
The compare function is called with two parameters that point to objects that are compared dur-
ing 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 rst parameter is less than, equal to, or greater
than the object pointed to by the second parameter.
The tdelete() function deletes a node from a binary search tree. Parameters for this function are
used in the same way as for the tsearch() function. The variable pointed to by the rootp parame-
ter is changed when the deleted node was the root of the binary tree. The tdelete() function
returns a pointer to the parent of the deleted node, or a null pointer if the node is not found.
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
The tdelete() function returns a pointer to the parent of the deleted node, or a null pointer if the
node is not found.
RELATED INFORMATION
Functions: bsearch(3), hsearch(3), lsearch(3), tnd(3), tsearch(3), twalk(3), qsort(3).
527192-005 Hewlett-Packard Company 75