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

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 Details

  • Constructor Details

  • Method Details

    • hasNext

      public boolean hasNext()
    • next

      public T next()