Class AbstractSuffixTree.AbstractNode

java.lang.Object
com.globalmentor.collections.AbstractSuffixTree.AbstractNode
All Implemented Interfaces:
SuffixTree.Node
Direct Known Subclasses:
CharSequenceSuffixTree.CharSequenceNode
Enclosing class:
AbstractSuffixTree<E extends SuffixTree.Edge>

protected abstract class AbstractSuffixTree.AbstractNode extends Object implements SuffixTree.Node
Represents a node in a suffix tree. Each node defaults to having no suffix node.
Author:
Garret Wilson
  • Constructor Details

    • AbstractNode

      public AbstractNode(int index)
      Index constructor. The node defaults to being a leaf node.
      Parameters:
      index - The index of the node.
  • Method Details

    • getIndex

      public int getIndex()
      Specified by:
      getIndex in interface SuffixTree.Node
      Returns:
      The index of the node.
    • isLeaf

      public boolean isLeaf()
      Specified by:
      isLeaf in interface SuffixTree.Node
      Returns:
      Whether this node is a leaf node in the suffix tree.
    • setLeaf

      protected void setLeaf(boolean leaf)
      Sets whether this node is a leaf.
      Parameters:
      leaf - Whether this node is a leaf.
    • getParentNode

      public SuffixTree.Node getParentNode()
      Specified by:
      getParentNode in interface SuffixTree.Node
      Returns:
      The parent node of this node, or null if this node has no parent node (i.e. it is the root node).
    • setParentNode

      protected void setParentNode(SuffixTree.Node parentNode)
      Sets the node indicating this node's parent.
      Parameters:
      parentNode - The node representing the parent of this node.
      Throws:
      NullPointerException - if the given node is null.
    • getSuffixNode

      public SuffixTree.Node getSuffixNode()
      Specified by:
      getSuffixNode in interface SuffixTree.Node
      Returns:
      The node representing the next smaller suffix, or null if there is no known smaller suffix node.
    • setSuffixNode

      protected void setSuffixNode(SuffixTree.Node suffixNode)
      Sets the node representing the next smaller suffix.
      Parameters:
      suffixNode - The node representing the next smaller suffix.
      Throws:
      NullPointerException - if the given node is null.
    • hashCode

      public int hashCode()
      This version returns the node index.
      Overrides:
      hashCode in class Object
      See Also:
    • equals

      public boolean equals(Object object)
      This version compares node indexes.
      Overrides:
      equals in class Object
      See Also:
    • toString

      public String toString()
      This implementation returns a string in the form (index)*, where '*' indicates a leaf node.
      Overrides:
      toString in class Object