Class IteratorUtility


  • public class IteratorUtility
    extends java.lang.Object
    Utility class to merge iterators.
    • Constructor Summary

      Constructors 
      Constructor Description
      IteratorUtility()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.PrimitiveIterator.OfLong mergeIteratorsForPrimitiveLongIterator​(java.util.Iterator<T> iter1, java.util.Iterator<T> iter2, java.util.Comparator<T> comparator, java.util.function.ToLongFunction<T> function)
      Merges two sorted iterators and returns merged iterator sorted using comparator.
      static java.util.PrimitiveIterator.OfLong mergePrimitiveLongIterator​(java.util.PrimitiveIterator.OfLong iter1, java.util.PrimitiveIterator.OfLong iter2)
      Merges two long primitive sorted iterators and returns merged iterator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IteratorUtility

        public IteratorUtility()
    • Method Detail

      • mergePrimitiveLongIterator

        public static java.util.PrimitiveIterator.OfLong mergePrimitiveLongIterator​(java.util.PrimitiveIterator.OfLong iter1,
                                                                                    java.util.PrimitiveIterator.OfLong iter2)
        Merges two long primitive sorted iterators and returns merged iterator. It expects - input iterators to be sorted - input iterators to be non-repetitive for merged iterator to be non-repetitive It removes duplicates from the input iterators.
        Parameters:
        iter1 - first primitive oflong input iterator
        iter2 - second primitive oflong input iterator
        Returns:
        merged primitive oflong iterator.
      • mergeIteratorsForPrimitiveLongIterator

        public static <T> java.util.PrimitiveIterator.OfLong mergeIteratorsForPrimitiveLongIterator​(java.util.Iterator<T> iter1,
                                                                                                    java.util.Iterator<T> iter2,
                                                                                                    java.util.Comparator<T> comparator,
                                                                                                    java.util.function.ToLongFunction<T> function)
        Merges two sorted iterators and returns merged iterator sorted using comparator. It uses 'function' to convert T type to long, to return long iterator. It expects - input iterators to be sorted - input iterators to be non-repetitive for merged iterator to be non-repetitive It removes duplicates from the input iterators.
        Parameters:
        iter1 - first iterator of type T
        iter2 - second iterator of type T
        comparator -
        function -
        Returns: