Module org.apache.lucene.core
Package org.apache.lucene.util
Class MergedIterator<T extends Comparable<T>>
java.lang.Object
org.apache.lucene.util.MergedIterator<T>
- All Implemented Interfaces:
Iterator<T>
Provides a merged sorted view from several sorted iterators.
If built with removeDuplicates set to true and an element appears in multiple
iterators then it is deduplicated, that is this iterator returns the sorted union of elements.
If built with removeDuplicates set to false then all elements in all iterators
are returned.
Caveats:
- The behavior is undefined if the iterators are not actually sorted.
- Null elements are unsupported.
- If removeDuplicates is set to true and if a single iterator contains duplicates then they will not be deduplicated.
- When elements are deduplicated it is not defined which one is returned.
- If removeDuplicates is set to false then the order in which duplicates are returned isn't defined.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classMergedIterator.SubIterator<I extends Comparable<I>>private static classMergedIterator.TermMergeQueue<C extends Comparable<C>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Tprivate intprivate final MergedIterator.TermMergeQueue<T> private final booleanprivate final MergedIterator.SubIterator<T>[] -
Constructor Summary
ConstructorsConstructorDescriptionMergedIterator(boolean removeDuplicates, Iterator<T>... iterators) MergedIterator(Iterator<T>... iterators) -
Method Summary
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
-
current
-
queue
-
top
-
removeDuplicates
private final boolean removeDuplicates -
numTop
private int numTop
-
-
Constructor Details
-
MergedIterator
-
MergedIterator
-
-
Method Details
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator<T extends Comparable<T>>
-
next
- Specified by:
nextin interfaceIterator<T extends Comparable<T>>
-
remove
public void remove()- Specified by:
removein interfaceIterator<T extends Comparable<T>>
-
pullTop
private void pullTop() -
pushTop
private void pushTop()
-