Class Tree

java.lang.Object
jadex.collection.Tree

public class Tree extends Object
Tree data structure.
  • Field Details

  • Constructor Details

    • Tree

      public Tree()
      Create a new tree.
    • Tree

      public Tree(TreeNode root)
      Create a new tree.
  • Method Details

    • getRootNode

      public TreeNode getRootNode()
      Return the root node of the tree.
      Returns:
      The root node.
    • setRootElement

      public void setRootElement(TreeNode root)
      Set the root node for the tree.
      Parameters:
      root - The root node to set.
    • toList

      public List toList(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.
    • isEmpty

      public boolean isEmpty()
      Test if empty.
    • toString

      public String toString()
      Returns a String representation of the tree. The elements are generated from a pre-order traversal of the tree.
      Overrides:
      toString in class Object
      Returns:
      the String representation of the Tree.
    • walkPreorder

      protected void walkPreorder(TreeNode node, List list)
      Walks the tree in pre-order style.
      Parameters:
      node - The starting element.
      list - The output of the walk.
    • walkPostorder

      protected void walkPostorder(TreeNode node, List list)
      Walks the tree in post-order style.
      Parameters:
      node - The starting element.
      list - The output of the walk.