Package org.passay.dictionary
Class AbstractWordList.WordListIterator
java.lang.Object
org.passay.dictionary.AbstractWordList.WordListIterator
- Enclosing class:
- AbstractWordList
An iterator over the
WordList.
The iteration order can be either sequential, i.e. incrementing an index from 0 to WordList.size() - 1,
or following a sequence of medians, i.e. the global median, followed by the median of the left half,
the median of the right half, the median of the left half of the left half, etc. (recursively).
The sequence of medians enables the creation of a well-balanced search tree from a sorted word list.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWordListIterator(boolean useMedians) Constructs a word list iterator. -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNext()next()voidremove()(package private) inttoMedianIndex(int i, int size) Returns the i-th element in the sequence of median indices of the given size.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
medians
protected final boolean mediansSpecifies whether to use medians or sequential order. -
index
protected int indexIndex of next word in the iterator sequence.
-
-
Constructor Details
-
WordListIterator
protected WordListIterator(boolean useMedians) Constructs a word list iterator.- Parameters:
useMedians- specifies whether to iterate in medians order or sequential order
-
-
Method Details
-
hasNext
public boolean hasNext() -
remove
public void remove() -
next
-
toMedianIndex
int toMedianIndex(int i, int size) Returns the i-th element in the sequence of median indices of the given size.- Parameters:
i- the index within the median sequence of the element to returnsize- the size of the sequence- Returns:
- the i-th element in the median indices sequence
-