Adds the specified node to the hierarchy and makes it a child of the specified parent. If the parent is not specified, then it makes the node a root.
boolean
addNode
(ref $node, optional $parent)
-
ref
$node: object The node to add.
-
optional
$parent: ref object parent The node that will become the parent of the added node.
Redefined in descendants as:
-
Tree::addNode()
: Adds the specified node to the tree and makes it a child of the specified parent. If the parent is not specified, then it makes the node a root. Always use this method instead of the addChild() method of the individual tree nodes.
Delete the node from the tree. This can only be done if the node has no parents and no children.
void
deleteNode
(object node $node)
-
object node
$node: The node to delete.
Redefined in descendants as:
-
Tree::deleteNode()
: Delete the node from the tree. This can only be done if the node has no parents and no children.
Simply returns all nodes of this hierarchy in an array in no particular order.
ref
getAllNodes
()
Returns all the ancestors of the given node.
array
getAncestors
(ref $node)
-
ref
$node: object node The node whose ancestors are to be found.
Returns the node with the specified id. If it does not exist, return
- null
.
ref
getNode
(string $id)
-
string
$id: id The id of the requested node.
Redefined in descendants as:
-
Tree::getNode()
: Returns the node with the specified id. If it does not exist, return
- null
.
Returns the size (number of nodes) in this hierarchy.
integer
getSize
()
Redefined in descendants as:
Returns the subtree rooted at the specified node (excluding the root).
array
getSubtree
(ref $node)
-
ref
$node: object node The node whose subtree is to be found.
Returns
- true
if the node with the specified id (string) exists.
boolean
nodeExists
(string $id)
-
string
$id: id The id of the node.
Redefined in descendants as:
Traverses the hierarchy and returns all the nodes in an array. The traversal is a pre-order traversal starting from the specified node.
ref
traverse
(optional $node)
-
optional
$node: ref object node An optional node to start traversal from.
Redefined in descendants as:
-
Tree::traverse()
: Traverses the tree and returns all the nodes in an array. The traversal is a depth-first pre-order traversal starting from the specified node.