org.parboiled.trees
Interface MutableTreeNode<T extends MutableTreeNode<T>>

Type Parameters:
T - the actual implementation type of this TreeNode
All Superinterfaces:
GraphNode<T>, TreeNode<T>
All Known Subinterfaces:
MutableBinaryTreeNode<T>
All Known Implementing Classes:
MutableBinaryTreeNodeImpl, MutableTreeNodeImpl

public interface MutableTreeNode<T extends MutableTreeNode<T>>
extends TreeNode<T>

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
 void addChild(int index, T child)
          Adds the given child to this nodes children list and setting the childs parent field to this node.
 T removeChild(int index)
          Removes the child with the given index.
 void setChild(int index, T child)
          Sets the child node at the given index to the given node.
 
Methods inherited from interface org.parboiled.trees.TreeNode
getParent
 
Methods inherited from interface org.parboiled.trees.GraphNode
getChildren
 

Method Detail

addChild

void addChild(int index,
              T child)
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 list
child - the child node to add

setChild

void setChild(int index,
              T child)
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 list
child - the child node to set

removeChild

T removeChild(int index)
Removes the child with the given index.

Parameters:
index - the index of the child to remove.
Returns:
the removed child