HP-UX Reference (11i v1 00/12) - 3 Library Functions N-Z (vol 7)
__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/nan.3m
________________________________________________________________
___ ___
t
tsearch(3C) tsearch(3C)
{
return strcmp(((struct element *) elem1)->string,
((struct element *) elem2)->string);
}
/* This routine prints out a node, the first time
twalk encounters it. */
void
print_node(element, order, level)
void *element;
VISIT order;
int level;
{
if (order == preorder || order == leaf)
{
(void) printf("string = %20s, length = %d\n",
(*(struct element **) element)->string,
(*(struct element **) element)->length);
}
}
RETURN VALUE
A NULL pointer is returned by tsearch() if there is not enough space available to create a new node.
A NULL pointer is returned by tsearch(), tfind(), and tdelete() if rootp isNULL on entry.
If the datum is found, both
tsearch() and tfind() return a pointer to it. If not, tfind() returns
NULL, and tsearch() returns a pointer to the inserted item.
WARNINGS
The root argument to twalk() is one level of indirection less than the rootp arguments to tsearch()
and tdelete().
Two nomenclatures are 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 the pointer to the root, results are unpredictable.
SEE ALSO
bsearch(3C), hsearch(3C), lsearch(3C).
STANDARDS CONFORMANCE
tsearch(): AES, SVID2, SVID3, XPG2, XPG3, XPG4
tdelete(): AES, SVID2, SVID3, XPG2, XPG3, XPG4
tfind(): AES, SVID2, SVID3, XPG2, XPG3, XPG4
twalk(): AES, SVID2, SVID3, XPG2, XPG3, XPG4
HP-UX Release 11i: December 2000 − 3 − Section 3−−989
___
___