Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4 |
both |
#define _XOPEN_SOURCE
#include <search.h>
void *twalk(const void *root, void (*action)(const void *, VISIT, int));
typedef enum {preorder, postorder, endorder, leaf } VISIT;
(defined
in the <search.h> header), depending on whether this is the
first, second or third time that the node is 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 the tree, with the
root being level zero.Threading Behavior: see tsearch() — Binary tree search.
Special behavior for C++: Because C and C++ linkage conventions are incompatible, twalk() cannot receive a C++ function pointer as the argument. If you attempt to pass a C++ function pointer to twalk(), the compiler will flag it as an error. You can pass a C or C++ function to twalk() by declaring it as extern "C".
twalk() returns no values.
No errors are defined.