Class Tree<T>

java.lang.Object
org.chsrobotics.lib.util.Tree<T>
Type Parameters:
T - Data type to be held by nodes.

public class Tree<T> extends Object
Implementation of a hierarchial tree data structure.

In a tree data structure, each node (except for a designated root) has exactly one parent node, and any number of children nodes.

  • Constructor Details

    • Tree

      public Tree(T rootData)
      Constructs a new tree.
      Parameters:
      rootData - Data to associate with the root of the tree.
  • Method Details

    • getBranchNodes

      public List<Tree.ParentChildNode<T>> getBranchNodes(Tree.ParentChildNode<T> stem)
      Returns all nodes that, at some point in their chain of parents, have a certain node as a parent.
      Parameters:
      stem - The node to find all descendants of.
      Returns:
      All nodes "downstream" of the supplied node, as well as the supplied node. Not in any particular order.
    • getAllNodes

      public List<Tree.ParentChildNode<T>> getAllNodes()
      Returns all nodes in the tree, including the root.
      Returns:
      All nodes in the tree, as a list in no particular order.