Package org.chsrobotics.lib.util
Class Tree<T>
java.lang.Object
org.chsrobotics.lib.util.Tree<T>
- Type Parameters:
T
- Data type to be held by nodes.
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Node part of a tree data structure. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns all nodes in the tree, including the root.getBranchNodes
(Tree.ParentChildNode<T> stem) Returns all nodes that, at some point in their chain of parents, have a certain node as a parent.
-
Constructor Details
-
Tree
Constructs a new tree.- Parameters:
rootData
- Data to associate with the root of the tree.
-
-
Method Details
-
getBranchNodes
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
Returns all nodes in the tree, including the root.- Returns:
- All nodes in the tree, as a list in no particular order.
-