Package org.apache.bookkeeper.util
Class IteratorUtility
java.lang.Object
org.apache.bookkeeper.util.IteratorUtility
Utility class to merge iterators.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> PrimitiveIterator.OfLongmergeIteratorsForPrimitiveLongIterator(Iterator<T> iter1, Iterator<T> iter2, Comparator<T> comparator, ToLongFunction<T> function) Merges two sorted iterators and returns merged iterator sorted using comparator.static PrimitiveIterator.OfLongMerges two long primitive sorted iterators and returns merged iterator.
-
Constructor Details
-
IteratorUtility
public IteratorUtility()
-
-
Method Details
-
mergePrimitiveLongIterator
public static PrimitiveIterator.OfLong mergePrimitiveLongIterator(PrimitiveIterator.OfLong iter1, 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> PrimitiveIterator.OfLong mergeIteratorsForPrimitiveLongIterator(Iterator<T> iter1, Iterator<T> iter2, Comparator<T> comparator, 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:
-