tdelete()

delete node from binary search tree 

Function


SYNOPSIS

#include <search.h>

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


DESCRIPTION

tdelete() deletes a node from a binary search tree. key is a pointer to the node to delete. rootp is the root of the tree to be traversed. The node pointed to by rootp is changed if the deleted node was the root of the tree.

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.

There are two nomenclatures used to refer to the order in which tree nodes are visited. tsearch() uses preorder, postorder, and endorder to respectively refer to visiting a node before any of its children, after its left child and before its right, and after both its children. The alternate nomenclature uses preorder, inorder, and postorder to refer to the same visits, which could result in some confusion over the meaning of postorder.

If the calling function alters rootp, results are unpredictable.


PARAMETERS

key 

Points to the node to delete.

rootp 

Points to a pointer to the root of the tree.

compar 

Is the comparator function.


RETURN VALUES

tdelete() returns a pointer to the parent of the deleted node, or a null pointer if the node is not found.


CONFORMANCE

UNIX 98.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

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


SEE ALSO

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


PTC MKS Toolkit 10.4 Documentation Build 39.