traverse


Description:

public void traverse (TraverseType order, TraverseFlags flags, int max_depth, NodeTraverseFunc<G> func)

Traverses a tree starting at the given root Node.

It calls the given function for each node visited. The traversal can be halted at any point by returning true from func. func must not do anything that would modify the structure of the tree.

Parameters:

this

the root Node of the tree to traverse

order

the order in which nodes are visited - g_in_order, g_pre_order, g_post_order, or g_level_order.

flags

which types of children are to be visited, one of g_traverse_all, g_traverse_leaves and g_traverse_non_leaves

max_depth

the maximum depth of the traversal. Nodes below this depth will not be visited. If max_depth is -1 all nodes in the tree are visited. If depth is 1, only the root is visited. If depth is 2, the root and its children are visited. And so on.

func

the function to call for each visited Node

data

user data to pass to the function