public class Tree<T>
extends java.lang.Object
Constructor and Description |
---|
Tree()
Default ctor.
|
Tree(Node<T> root)
Creates a tree from the supplied root
|
Tree(T data)
Creates a tree from the supplied root
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
consolidate()
Merges branches if the nodes have equal content
i.e. |
static void |
consolidate(Tree<?> tree)
Merges branches if the nodes have equal content
i.e.
|
Node<T> |
getRootElement()
Return the root Node of the tree.
|
void |
setRootElement(Node<T> rootElement)
Set the root Element for the tree.
|
java.util.List<Node<T>> |
toList()
Returns the Tree
|
java.lang.String |
toString()
Returns a String representation of the Tree.
|
public Tree()
public Tree(Node<T> root)
root
- the root element.public Tree(T data)
data
- the data for the root element.public Node<T> getRootElement()
public void setRootElement(Node<T> rootElement)
rootElement
- the root element to set.public java.util.List<Node<T>> toList()
public java.lang.String toString()
toString
in class java.lang.Object
public void clear()
public static void consolidate(Tree<?> tree)
public void consolidate()