This module provides a convenience function to build a tree of objects
in a single command. You supply a callback to create node and the
function will connect the parent and children nodes for you.
The callback is called with these arguments:
($parent, $level, $seniority)
where $parent is the parent node object (or undef if creating the root
node, which is the first time the callback is called), $level indicates
the current depth of the tree (starting from 0 for the root node, then
1 for the root's children, then 2 for their children, and so on). You
can use this argument to know where to stop creating nodes. $seniority
indicates the position of the node against its sibling (0 means the
node is the first child of its parent, 1 means the second, and so on).
You can use this argument to perhaps customize the node according to
its sibling order.
The callback should return a list:
($node, $num_children)
where $node is the created node object (the object can be of any class
but it must respond to parent and children, see
Role::TinyCommons::Tree::Node for more details on the requirement),
$num_children is an integer that specifies the number of children that
this node should have (0 means this node is to be a leaf node). The
children will be created when the function calls the callback again
later for each child node.
FUNCTIONS
create_tree_using_callback($cb) => obj
SEE ALSO
Other Tree::Create::* modules, e.g. Tree::Create::Size.
Other ways to create tree: Tree::FromStruct, Tree::FromText,
Tree::FromTextLines.