twalk()

traverse binary search tree 

Function


SYNOPSIS

#include <search.h>

void twalk (void * root, void (*action)(const void *, VISIT, int));


DESCRIPTION

twalk() traverses a binary search tree. rootp is the root node of the tree to be traversed. (Any node in a tree may be used as the root for a walk below that node.) action is the name of the routine to be invoked at each node. This routine is, in turn, called with three arguments. The first argument is the address of the node being visited. Ths second argument is a value from an enumeration data type typedef enum {preorder, postorder, endorder, leaf} VISIT; (defined in the <search.h> header file), depending on whether this is the first, second, or third time that the node has been visited (during a depth-first, left-to-right traversal of the tree), or whether the node is a leaf. The third argument is the level of the node in a tree, with the root being level zero.

Note:

The rootp argument to twalk() is one level of indirection less than the rootp arguments to tsearch() and tdelete()

twalk() 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.

If the calling function alters rootp, results are unpredictable.


PARAMETERS

rootp 

Points to the root of the tree.

action 

Is the action routine to be invoked at each node.


RETURN VALUES

None.


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(), tdelete(), tfind(), tsearch()


PTC MKS Toolkit 10.4 Documentation Build 39.