Package com.saperion.util
Class ParallelIterator<Type1,Type2>
java.lang.Object
com.saperion.util.ParallelIterator<Type1,Type2>
An iterator that iterates over two iterators simultaneously. Expects the ranges of both iterators to have the
same length.
-
Constructor Summary
ConstructorsConstructorDescriptionParallelIterator
(Iterator<Type1> iterator1, Iterator<Type2> iterator2) Creates aParallelIterator
that iterates over the giveniterators
simultaneously. -
Method Summary
Modifier and TypeMethodDescriptionstatic <Type1,
Type2>
ParallelIterator<Type1,Type2> Convenience method that wraps the constructor call and lets the compiler determine the generic types.boolean
hasNext()
next()
The result will hold the result of theIterator.next()
call of the first iterator first, then the one of the second iterator.void
remove()
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
-
Constructor Details
-
ParallelIterator
Creates aParallelIterator
that iterates over the giveniterators
simultaneously.- Parameters:
iterator1
- the first iterator to iterate over. The return values of itsIterator.next()
method will be first in the result pair of thenext()
method.iterator2
- the second iterator to iterate over. The return values of itsIterator.next()
method will be second in the result pair of thenext()
method.
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
The result will hold the result of theIterator.next()
call of the first iterator first, then the one of the second iterator. -
remove
public void remove() -
create
public static <Type1,Type2> ParallelIterator<Type1,Type2> create(Iterator<Type1> iterator1, Iterator<Type2> iterator2) Convenience method that wraps the constructor call and lets the compiler determine the generic types. -
parallel
-