Package org.parboiled.trees
Interface MutableTreeNode<T extends MutableTreeNode<T>>
- Type Parameters:
T
- the actual implementation type of this TreeNode
- All Known Subinterfaces:
MutableBinaryTreeNode<T>
- All Known Implementing Classes:
MutableBinaryTreeNodeImpl
,MutableTreeNodeImpl
A
TreeNode
specialiation that allow for mutability of the tree structure.
The three defined methods are all expected to properly uphold the trees "linking back" contract, where children
have their parent fields point to the node actually holding them in their children list at all times.
The three defined methods are the basic ones required, other convenience methods (like a simple addChild(child)
without index) are defined as static methods of the TreeUtils
class.-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given child to this nodes children list and setting the childs parent field to this node.removeChild
(int index) Removes the child with the given index.void
Sets the child node at the given index to the given node.Methods inherited from interface org.parboiled.trees.GraphNode
getChildren
-
Method Details
-
addChild
Adds the given child to this nodes children list and setting the childs parent field to this node. If the child is currently attached to another node it is first removed.- Parameters:
index
- the index under which to insert this child into the children listchild
- the child node to add
-
setChild
Sets the child node at the given index to the given node. The node previously existing at the given child index is first properly removed by setting its parent field to null. If the child is currently attached to another node it is first removed from its old parent.- Parameters:
index
- the index under which to set this child into the children listchild
- the child node to set
-
removeChild
Removes the child with the given index.- Parameters:
index
- the index of the child to remove.- Returns:
- the removed child
-