Package jadex.collection
Class Tree
java.lang.Object
jadex.collection.Tree
Tree data structure.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn the root node of the tree.boolean
isEmpty()
Test if empty.void
setRootElement
(TreeNode root) Set the root node for the tree.Returns the tree as a List of node objects.toString()
Returns a String representation of the tree.protected void
walkPostorder
(TreeNode node, List list) Walks the tree in post-order style.protected void
walkPreorder
(TreeNode node, List list) Walks the tree in pre-order style.
-
Field Details
-
PREORDER
The preorder constant.- See Also:
-
POSTORDER
The postorder constant.- See Also:
-
root
The root node.
-
-
Constructor Details
-
Tree
public Tree()Create a new tree. -
Tree
Create a new tree.
-
-
Method Details
-
getRootNode
Return the root node of the tree.- Returns:
- The root node.
-
setRootElement
Set the root node for the tree.- Parameters:
root
- The root node to set.
-
toList
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.
-
isEmpty
public boolean isEmpty()Test if empty. -
toString
Returns a String representation of the tree. The elements are generated from a pre-order traversal of the tree. -
walkPreorder
Walks the tree in pre-order style.- Parameters:
node
- The starting element.list
- The output of the walk.
-
walkPostorder
Walks the tree in post-order style.- Parameters:
node
- The starting element.list
- The output of the walk.
-