Adds a new child node based on a value
Projects node as a dynamic traversable.
Dynamic in the sense that it creates the traversable project for nodes on demand.
A consequence is that node identities are not stable.
Breadth-first iteration of the children of node
Iterate over direct children of root, yielding TreeNode instances.
Use childrenValues to iterate over child values
Compares two nodes.
Computes the maximum depth of the tree.
That is, how many steps down from node it can go.
If a tree is: root -> childA -> subChildB
Creates a TreeNode instance with a given value and parent.
Parent node, if specified, has its childrenStore property changed to include new child.
Depth-first iteration of the children of node
Using a breadth-first search, return the first child of parent that has value.
Returns the first immediate child of parent that matches value.
Returns the first parent that has a given value.
Traverses up a node to find the root.
Returns true if prospectiveChild is some child node of parent,
anywhere in the tree structure.
Returns true if prospectiveParent is any ancestor
parent of child.
Returns true if child is an immediate child of parent.
Returns true if prospectiveParent is the immediate
parent of child.
Returns the depth of node. A root node (ie. with no parents) has a depth of 0.
Iterate over all parents of child. First result is the immediate parent.
Yields the node value of each parent of child.
undefined values are not returned.
Yield all immediate children of parent that match value.
Yields all parents of child that have a given value.
Use findParentsValue to find the first match only.
Removes child from the tree structure it is in.
It removes child from its parent. Any sub-children of child still remain connected.
Starting from a child node, work backwards, removing it and ancestors that have no value
Creates the root for a tree, with an optional value.
Use rootWrapped if you want a more object-oriented mode of access.
Creates a tree, returning it as a WrappedNode for object-oriented access. Use Trees.Mutable.root alternatively.
Sets the children of parent to a list of children.
Enumeate all siblings of child. This won't include child itself.
If child is not part of a tree (ie has no parent) no values are yielded.
Converts Trees.TreeNode to Trees.SimplifiedNode, removing the 'parent' fields. This can be useful because if you have the whole tree, the parent field is redundant and because it makes circular references can make dumping to console etc more troublesome.
Throws an exception if root fails tree validation
Validates the tree from root downwards.
Wraps node n for a more object-oriented means of access.
It will wrap child nodes on demand. For this reason, WrappedNode object
identity is not stable
Adds a child node to
parent. Ifchildalready has a parent, it is removed from that parent.