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:
java.util.Iterator<T>
- Enclosing class:
- Iterators
private static class Iterators.MergingIterator<T> extends UnmodifiableIterator<T>
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 Modifier and Type Field Description (package private) java.util.Queue<PeekingIterator<T>>
queue
-
Constructor Summary
Constructors Constructor Description MergingIterator(java.lang.Iterable<? extends java.util.Iterator<? extends T>> iterators, java.util.Comparator<? super T> itemComparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
T
next()
-
Methods inherited from class com.google.common.collect.UnmodifiableIterator
remove
-
-
-
-
Field Detail
-
queue
final java.util.Queue<PeekingIterator<T>> queue
-
-
Method Detail
-
hasNext
public boolean hasNext()
-
next
public T next()
-
-