Class MergeSortedIterator<A,​E>

  • Type Parameters:
    A -
    E -
    All Implemented Interfaces:

    public class MergeSortedIterator<A,​E>
    extends java.lang.Object
    implements java.util.Iterator<E>
    This Iterator take two sorted iterators and merge them. Loop over iterators and use comparator in order to take items that are equals. The merge is done using the function mergeFunction
    • Constructor Summary

      Constructor Description
      MergeSortedIterator​(java.util.Iterator<A> one, java.util.Iterator<A> two, java.util.Comparator<A> comparator, java.util.function.BiFunction<A,​A,​E> mergeFunction)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      E next()  
      • 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, remove
    • Constructor Detail

      • MergeSortedIterator

        public MergeSortedIterator​(java.util.Iterator<A> one,
                                   java.util.Iterator<A> two,
                                   java.util.Comparator<A> comparator,
                                   java.util.function.BiFunction<A,​A,​E> mergeFunction)
        one - The first sorted iterator
        two - The second sorted iterator
        comparator - The comparator that compare items of iterators
        mergeFunction - The function that merge elements of iterators
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<A>
      • next

        public E next()
        Specified by:
        next in interface java.util.Iterator<A>