Class Tree.ParentChildNode<U>

java.lang.Object
org.chsrobotics.lib.util.Tree.ParentChildNode<U>
Type Parameters:
U - Data type held by this node.
Enclosing class:
Tree<T>

public static class Tree.ParentChildNode<U> extends Object
Node part of a tree data structure. This node can have multiple children but only one parent.
  • Field Details

    • parent

      public final Tree.ParentChildNode<U> parent
      The parent of this node. If this node does not have a parent, is null.
    • isRoot

      public final boolean isRoot
      Whether this node is root of the tree structure.
  • Constructor Details

    • ParentChildNode

      public ParentChildNode(U data, Tree.ParentChildNode<U> parent)
      Constructs a ParentChildNode.
      Parameters:
      data - The data to associate with this node.
      parent - The parent of this node.
  • Method Details

    • constructAsChild

      public Tree.ParentChildNode<U> constructAsChild(U data)
      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

      public U getData()
      Returns the data associated with this node.
      Returns:
      An instance of U.
    • setData

      public void setData(U data)
      Sets the new data associated with this node.
      Parameters:
      data - A new instance of U.
    • getChildren

      public List<Tree.ParentChildNode<U>> getChildren()
      Returns all children of this node.
      Returns:
      A list containing all children of this node.