Package org.chsrobotics.lib.util
Class Tree.ParentChildNode<U>
java.lang.Object
org.chsrobotics.lib.util.Tree.ParentChildNode<U>
- Type Parameters:
U- Data type held by this node.
Node part of a tree data structure. This node can have multiple children but only one parent.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal booleanWhether this node is root of the tree structure.final Tree.ParentChildNode<U>The parent of this node. -
Constructor Summary
ConstructorsConstructorDescriptionParentChildNode(U data, Tree.ParentChildNode<U> parent) Constructs a ParentChildNode. -
Method Summary
Modifier and TypeMethodDescriptionconstructAsChild(U data) Constructs and returns a new node as a child of this node.Returns all children of this node.getData()Returns the data associated with this node.voidSets the new data associated with this node.
-
Field Details
-
parent
The parent of this node. If this node does not have a parent, isnull. -
isRoot
public final boolean isRootWhether this node is root of the tree structure.
-
-
Constructor Details
-
ParentChildNode
Constructs a ParentChildNode.- Parameters:
data- The data to associate with this node.parent- The parent of this node.
-
-
Method Details
-
constructAsChild
Constructs and returns a new node as a child of this node.- Parameters:
data- Data to associate with the new node.- Returns:
- A new child of this node.
-
getData
Returns the data associated with this node.- Returns:
- An instance of U.
-
setData
Sets the new data associated with this node.- Parameters:
data- A new instance of U.
-
getChildren
Returns all children of this node.- Returns:
- A list containing all children of this node.
-