Function bstree_traverse
Defined in File bstree.h
Function Documentation
-
int bstree_traverse(struct bstree *tree, int (*cb)(const struct bstree *tree, struct bstree_node *node), enum bstree_traversal_type type)
Traverse a binary search tree and operate on each node’s data.
Can traverse in a pre-order, post-order, or in-order way.
If the callback returns nonzero on a given node, then the traversal is aborted.
- Parameters:
tree – The BST handle
cb – Callback called on each node in the tree, and passed the BST handle. Cannot be used to modify the BST handle, but CAN modify the node.
type – The type of traversal to perform.
- Returns:
Return code of last callback that was non-zero, or 0 if callback succeeded on all nodes