Package com.google.common.collect
Class Iterators.MergingIterator<T>
java.lang.Object
com.google.common.collect.UnmodifiableIterator<T>
com.google.common.collect.Iterators.MergingIterator<T>
- All Implemented Interfaces:
Iterator<T>
- Enclosing class:
Iterators
An iterator that performs a lazy N-way merge, calculating the next value each time the iterator
is polled. This amortizes the sorting cost over the iteration and requires less memory than
sorting all elements at once.
Retrieving a single element takes approximately O(log(M)) time, where M is the number of iterators. (Retrieving all elements takes approximately O(N*log(M)) time, where N is the total number of elements.)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMergingIterator
(Iterable<? extends Iterator<? extends T>> iterators, Comparator<? super T> itemComparator) -
Method Summary
Methods inherited from class com.google.common.collect.UnmodifiableIterator
remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
queue
-
-
Constructor Details
-
MergingIterator
public MergingIterator(Iterable<? extends Iterator<? extends T>> iterators, Comparator<? super T> itemComparator)
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
-