Package com.globalmentor.collections
Class CharSequenceSuffixTree.CharSequenceEdge
- java.lang.Object
-
- com.globalmentor.collections.CharSequenceSuffixTree.AbstractEdgeKey
-
- com.globalmentor.collections.CharSequenceSuffixTree.CharSequenceEdge
-
- All Implemented Interfaces:
CharSequenceSuffixTree.EdgeKey
,SuffixTree.Edge
- Enclosing class:
- CharSequenceSuffixTree
protected class CharSequenceSuffixTree.CharSequenceEdge extends CharSequenceSuffixTree.AbstractEdgeKey implements SuffixTree.Edge
Represents an edge between a parent node and a child node in a suffix tree.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description CharSequenceEdge(CharSequenceSuffixTree.CharSequenceNode parentNode, CharSequenceSuffixTree.CharSequenceNode childNode, int start, int end)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<CharSequenceSuffixTree.CharSequenceEdge>
getChildEdges()
CharSequenceSuffixTree.CharSequenceNode
getChildNode()
int
getEnd()
char
getFirstChar()
int
getLength()
Returns the length of the edge, i.e.SuffixTree.Node
getParentNode()
int
getStart()
java.lang.CharSequence
getSubSequence()
boolean
isEmpty()
boolean
startsWith(java.lang.CharSequence charSequence)
Compares a character sequence with the characters at the start of this child edge and continuing along child edges.boolean
startsWith(java.lang.CharSequence charSequence, int start, int end)
Compares part of a character sequence with the characters at the start of this child edge and continuing along child edges.java.lang.String
toString()
-
Methods inherited from class com.globalmentor.collections.CharSequenceSuffixTree.AbstractEdgeKey
equals, hashCode
-
-
-
-
Constructor Detail
-
CharSequenceEdge
public CharSequenceEdge(CharSequenceSuffixTree.CharSequenceNode parentNode, CharSequenceSuffixTree.CharSequenceNode childNode, int start, int end)
Constructor.- Parameters:
parentNode
- The parent node representing the root end of the edge.childNode
- The child node representing the leaf end of the edge.start
- The position of the start character, inclusive.end
- The position of the end character, exclusive.- Throws:
java.lang.NullPointerException
- if the given parent node and/or child node isnull
.java.lang.IllegalArgumentException
- if the given end is less than the start.
-
-
Method Detail
-
getParentNode
public SuffixTree.Node getParentNode()
- Specified by:
getParentNode
in interfaceCharSequenceSuffixTree.EdgeKey
- Specified by:
getParentNode
in interfaceSuffixTree.Edge
- Returns:
- The parent node representing the root end of the edge.
-
getChildNode
public CharSequenceSuffixTree.CharSequenceNode getChildNode()
- Specified by:
getChildNode
in interfaceSuffixTree.Edge
- Returns:
- The child node representing the leaf end of the edge.
-
getStart
public int getStart()
- Specified by:
getStart
in interfaceSuffixTree.Edge
- Returns:
- The position of the start character, inclusive.
-
getEnd
public int getEnd()
- Specified by:
getEnd
in interfaceSuffixTree.Edge
- Returns:
- The position of the last character, exclusive.
-
getLength
public int getLength()
Returns the length of the edge, i.e.end
-start
.- Specified by:
getLength
in interfaceSuffixTree.Edge
- Returns:
- The number of characters on the edge.
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceSuffixTree.Edge
- Returns:
true
if this edge is empty and has no characters.
-
getFirstChar
public char getFirstChar()
- Specified by:
getFirstChar
in interfaceCharSequenceSuffixTree.EdgeKey
- Returns:
- The first character of the edge.
-
getSubSequence
public java.lang.CharSequence getSubSequence()
- Returns:
- The subsequence of characters this edge represents.
-
getChildEdges
public java.lang.Iterable<CharSequenceSuffixTree.CharSequenceEdge> getChildEdges()
- Specified by:
getChildEdges
in interfaceSuffixTree.Edge
- Returns:
- An iterable to the child edges of this edge's child node.
-
startsWith
public boolean startsWith(java.lang.CharSequence charSequence)
Compares a character sequence with the characters at the start of this child edge and continuing along child edges.- Parameters:
charSequence
- The character sequence to compare.- Returns:
true
if there is a path matching the given character sequence starting at this edge and continuing along child edges.- See Also:
CharSequenceSuffixTree.CharSequenceNode.startsWith(CharSequence)
-
startsWith
public boolean startsWith(java.lang.CharSequence charSequence, int start, int end)
Compares part of a character sequence with the characters at the start of this child edge and continuing along child edges.- Parameters:
charSequence
- The character sequence to compare.start
- The start of the character sequence to compare, inclusive.end
- The end of the character sequence to compare, exclusive.- Returns:
true
if there is a path matching the given character sequence starting at this edge and continuing along child edges.- Throws:
java.lang.StringIndexOutOfBoundsException
- ifstart
orend
are negative or greater thanlength()
, orstart
is greater thanend
.- See Also:
CharSequenceSuffixTree.CharSequenceNode.startsWith(CharSequence, int, int)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-