public class Tree
extends java.lang.Object
| Modifier and Type | Field and Description | 
|---|---|
| static java.lang.String | POSTORDERThe postorder constant. | 
| static java.lang.String | PREORDERThe preorder constant. | 
| protected TreeNode | rootThe root node. | 
| Constructor and Description | 
|---|
| Tree()Create a new tree. | 
| Tree(TreeNode root)Create a new tree. | 
| Modifier and Type | Method and Description | 
|---|---|
| TreeNode | getRootNode()Return the root node of the tree. | 
| boolean | isEmpty()Test if empty. | 
| void | setRootElement(TreeNode root)Set the root node for the tree. | 
| java.util.List | toList(java.lang.String order)Returns the tree as a List of node objects. | 
| java.lang.String | toString()Returns a String representation of the tree. | 
| protected void | walkPostorder(TreeNode node,
             java.util.List list)Walks the tree in post-order style. | 
| protected void | walkPreorder(TreeNode node,
            java.util.List list)Walks the tree in pre-order style. | 
public static final java.lang.String PREORDER
public static final java.lang.String POSTORDER
protected TreeNode root
public Tree()
public Tree(TreeNode root)
public TreeNode getRootNode()
public void setRootElement(TreeNode root)
root - The root node to set.public java.util.List toList(java.lang.String order)
public boolean isEmpty()
public java.lang.String toString()
toString in class java.lang.Objectprotected void walkPreorder(TreeNode node, java.util.List list)
node - The starting element.list - The output of the walk.protected void walkPostorder(TreeNode node, java.util.List list)
node - The starting element.list - The output of the walk.