Class SimpleTreeNode<V,K>

java.lang.Object
io.github.astrapi69.gen.tree.SimpleTreeNode<V,K>
Type Parameters:
V - the generic type of the value
K - the generic type of the id of the node
All Implemented Interfaces:
io.github.astrapi69.design.pattern.visitor.Acceptable<io.github.astrapi69.design.pattern.visitor.Visitor<SimpleTreeNode<V,K>>>

public class SimpleTreeNode<V,K> extends Object implements io.github.astrapi69.design.pattern.visitor.Acceptable<io.github.astrapi69.design.pattern.visitor.Visitor<SimpleTreeNode<V,K>>>
The generic class SimpleTreeNode holds only the parent, the left most child and the right sibling
  • Constructor Details

    • SimpleTreeNode

      public SimpleTreeNode(V value)
      Instantiates a new SimpleTreeNode object
      Parameters:
      value - the value
  • Method Details

    • getLevel

      public int getLevel()
      Returns the distance from the root to this node. Returns 0 if this node is the root.
      Returns:
      the level from this node.
    • getRoot

      public SimpleTreeNode<V,K> getRoot()
      Gets the root SimpleTreeNode object
      Returns:
      the root SimpleTreeNode object
    • isRoot

      public boolean isRoot()
      Checks if this SimpleTreeNode is the root SimpleTreeNode object
      Returns:
      true, if this SimpleTreeNode is the root SimpleTreeNode object
    • isNode

      public boolean isNode()
      Checks if this SimpleTreeNode object is a node
      Returns:
      true, if this SimpleTreeNode object is a node otherwise false
    • getAllSiblings

      public Collection<SimpleTreeNode<V,K>> getAllSiblings()
      Gets all the siblings from this node
      Returns:
      all the siblings from this node
    • getAllLeftSiblings

      public Collection<SimpleTreeNode<V,K>> getAllLeftSiblings()
      Gets all the left siblings from this node
      Returns:
      all the left siblings from this node
    • getAllRightSiblings

      public Collection<SimpleTreeNode<V,K>> getAllRightSiblings()
      Gets all the right siblings from this node
      Returns:
      all the right siblings from this node
    • hasParent

      public boolean hasParent()
      Checks if this node has a parent
      Returns:
      true, if successful
    • hasRightSibling

      public boolean hasRightSibling()
      Checks if this node has a right sibling
      Returns:
      true, if successful
    • hasLeftMostChild

      public boolean hasLeftMostChild()
      Checks if this node has a left most child
      Returns:
      true, if successful
    • traverse

      public Collection<SimpleTreeNode<V,K>> traverse()
      Traverse this node and add all descendants with this included in to a Set
      Returns:
      a Set with this node and add all descendants
    • getChildren

      public Collection<SimpleTreeNode<V,K>> getChildren()
      Gets the children
      Returns:
      the children
    • accept

      public void accept(io.github.astrapi69.design.pattern.visitor.Visitor<SimpleTreeNode<V,K>> visitor)
      Specified by:
      accept in interface io.github.astrapi69.design.pattern.visitor.Acceptable<V>