Package org.apache.bookkeeper.util
Class IteratorUtility
- java.lang.Object
-
- org.apache.bookkeeper.util.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.
-
-
-
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 iteratoriter2
- 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 Titer2
- second iterator of type Tcomparator
-function
-- Returns:
-
-