public final class WordSequence extends java.lang.Object implements java.lang.Comparable<WordSequence>
Modifier and Type | Field and Description |
---|---|
static WordSequence |
EMPTY
an empty word sequence, that is, it has no words.
|
static java.util.Comparator<WordSequence> |
OLDEST_COMPARATOR
Comparator that compares two sequences by their oldest part.
|
Constructor and Description |
---|
WordSequence(java.util.List<Word> list)
Constructs a word sequence from the list of words
|
WordSequence(Word... words)
Constructs a word sequence with the given word IDs
|
Modifier and Type | Method and Description |
---|---|
WordSequence |
addWord(Word word,
int maxSize)
Returns a new word sequence with the given word added to the sequence
|
static WordSequence |
asWordSequence(Dictionary dictionary,
java.lang.String... words) |
int |
compareTo(WordSequence other) |
boolean |
equals(java.lang.Object object)
compares the given object to see if it is identical to this WordSequence
|
WordSequence |
getNewest()
Returns the newest words in the sequence (the old word is omitted)
|
WordSequence |
getOldest()
Returns the oldest words in the sequence (the newest word is omitted)
|
WordSequence |
getSubSequence(int startIndex,
int stopIndex) |
Word |
getWord(int n)
Returns the n-th word in this sequence
|
Word[] |
getWords() |
int |
hashCode()
Calculates the hashcode for this object
|
int |
size()
Returns the number of words in this sequence
|
java.lang.String |
toString()
Returns a string representation of this word sequence.
|
WordSequence |
trim(int maxSize)
Returns a word sequence that is no longer than the given size, that is
filled in with the newest words from this sequence
|
public static final java.util.Comparator<WordSequence> OLDEST_COMPARATOR
public static final WordSequence EMPTY
public WordSequence(Word... words)
words
- the word IDs of the word sequencepublic WordSequence(java.util.List<Word> list)
list
- the list of wordspublic static WordSequence asWordSequence(Dictionary dictionary, java.lang.String... words)
public WordSequence addWord(Word word, int maxSize)
word
- the word to add to the sequencemaxSize
- the maximum size of the generated sequencepublic WordSequence getOldest()
public WordSequence getNewest()
public WordSequence trim(int maxSize)
maxSize
- the maximum size of the sequencepublic Word getWord(int n)
n
- which word to returnpublic int size()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- the object to compare this topublic WordSequence getSubSequence(int startIndex, int stopIndex)
startIndex
- start indexstopIndex
- stop indexstartIndex
and
stopIndex
exclusive.public Word[] getWords()
WordSequence
.public int compareTo(WordSequence other)
compareTo
in interface java.lang.Comparable<WordSequence>