public final class TreeUtils
extends java.lang.Object
TreeNode
s.Modifier | Constructor and Description |
---|---|
private |
TreeUtils() |
Modifier and Type | Method and Description |
---|---|
static <T extends MutableTreeNode<T>> |
addChild(T parent,
T child)
Adds a new child node to a given MutableTreeNode parent.
|
static <T extends TreeNode<T>> |
getRoot(T node)
Returns the root of the tree the given node is part of.
|
static <T extends MutableTreeNode<T>> |
removeChild(T parent,
T child)
Removes the given child from the given parent node.
|
static <N extends MutableBinaryTreeNode<N>> |
toLeftAssociativity(N node)
Performs the following transformation on the given MutableBinaryTreeNode:
|
public static <T extends TreeNode<T>> T getRoot(T node)
node
- the node to get the root ofpublic static <T extends MutableTreeNode<T>> void addChild(T parent, T child)
parent
- the parent nodechild
- the child node to addpublic static <T extends MutableTreeNode<T>> void removeChild(T parent, T child)
parent
- the parent nodechild
- the child nodepublic static <N extends MutableBinaryTreeNode<N>> N toLeftAssociativity(N node)
o1 o2 / \ / \ A o2 ====> o1 C / \ / \ B C A B
node
- the node to transform