Package jadex.commons.collection
Class Tree
- java.lang.Object
- 
- jadex.commons.collection.Tree
 
- 
 public class Tree extends java.lang.ObjectTree data structure.
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description TreeNodegetRootNode()Return the root node of the tree.booleanisEmpty()Test if empty.voidsetRootElement(TreeNode root)Set the root node for the tree.java.util.ListtoList(java.lang.String order)Returns the tree as a List of node objects.java.lang.StringtoString()Returns a String representation of the tree.protected voidwalkPostorder(TreeNode node, java.util.List list)Walks the tree in post-order style.protected voidwalkPreorder(TreeNode node, java.util.List list)Walks the tree in pre-order style.
 
- 
- 
- 
Field Detail- 
PREORDERpublic static final java.lang.String PREORDER The preorder constant.- See Also:
- Constant Field Values
 
 - 
POSTORDERpublic static final java.lang.String POSTORDER The postorder constant.- See Also:
- Constant Field Values
 
 - 
rootprotected TreeNode root The root node.
 
- 
 - 
Constructor Detail- 
Treepublic Tree() Create a new tree.
 - 
Treepublic Tree(TreeNode root) Create a new tree.
 
- 
 - 
Method Detail- 
getRootNodepublic TreeNode getRootNode() Return the root node of the tree.- Returns:
- The root node.
 
 - 
setRootElementpublic void setRootElement(TreeNode root) Set the root node for the tree.- Parameters:
- root- The root node to set.
 
 - 
toListpublic java.util.List toList(java.lang.String order) Returns the tree as a List of node objects. The elements of the List are generated from a pre-order traversal of the tree.- Returns:
- Tree elements.
 
 - 
isEmptypublic boolean isEmpty() Test if empty.
 - 
toStringpublic java.lang.String toString() Returns a String representation of the tree. The elements are generated from a pre-order traversal of the tree.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- the String representation of the Tree.
 
 - 
walkPreorderprotected void walkPreorder(TreeNode node, java.util.List list) Walks the tree in pre-order style.- Parameters:
- node- The starting element.
- list- The output of the walk.
 
 - 
walkPostorderprotected void walkPostorder(TreeNode node, java.util.List list) Walks the tree in post-order style.- Parameters:
- node- The starting element.
- list- The output of the walk.
 
 
- 
 
-