Class MergeSortedIterators<T>

  • Type Parameters:
    T - the entry type
    All Implemented Interfaces:
    Iterator<T>

    public abstract class MergeSortedIterators<T>
    extends Object
    implements Iterator<T>
    MergeSortedIterators is a specialized implementation of a merge sort of already sorted iterators of some type of comparable elements. The input iterators must return the elements in sorted order according to the provided Comparator. In addition the sequence of iterators must also be sorted in a way that the first element of the next iterator is greater than the first element of the previous iterator.
    • Constructor Detail

      • MergeSortedIterators

        public MergeSortedIterators​(Comparator<T> comparator)
    • Method Detail

      • nextIterator

        public abstract Iterator<T> nextIterator()
        Returns:
        the next Iterator or null if there is none.
      • description

        public String description()
        Provides details about this iterator
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<T>
      • next

        public T next()
        Specified by:
        next in interface Iterator<T>
      • remove

        public void remove()
        Specified by:
        remove in interface Iterator<T>