Package com.saperion.util
Class ParallelIterator<Type1,Type2>
- java.lang.Object
-
- com.saperion.util.ParallelIterator<Type1,Type2>
-
- All Implemented Interfaces:
java.util.Iterator<Pair<Type1,Type2>>
public class ParallelIterator<Type1,Type2> extends java.lang.Object implements java.util.Iterator<Pair<Type1,Type2>>
An iterator that iterates over two iterators simultaneously. Expects the ranges of both iterators to have the same length.
-
-
Constructor Summary
Constructors Constructor Description ParallelIterator(java.util.Iterator<Type1> iterator1, java.util.Iterator<Type2> iterator2)
Creates aParallelIterator
that iterates over the giveniterators
simultaneously.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <Type1,Type2>
ParallelIterator<Type1,Type2>create(java.util.Iterator<Type1> iterator1, java.util.Iterator<Type2> iterator2)
Convenience method that wraps the constructor call and lets the compiler determine the generic types.boolean
hasNext()
Pair<Type1,Type2>
next()
The result will hold the result of theIterator.next()
call of the first iterator first, then the one of the second iterator.static <Type1,Type2>
java.lang.Iterable<Pair<Type1,Type2>>parallel(java.lang.Iterable<Type1> iterable1, java.lang.Iterable<Type2> iterable2)
void
remove()
-
-
-
Constructor Detail
-
ParallelIterator
public ParallelIterator(java.util.Iterator<Type1> iterator1, java.util.Iterator<Type2> iterator2)
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 Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<Type1>
-
next
public Pair<Type1,Type2> next()
The result will hold the result of theIterator.next()
call of the first iterator first, then the one of the second iterator.- Specified by:
next
in interfacejava.util.Iterator<Type1>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<Type1>
-
create
public static <Type1,Type2> ParallelIterator<Type1,Type2> create(java.util.Iterator<Type1> iterator1, java.util.Iterator<Type2> iterator2)
Convenience method that wraps the constructor call and lets the compiler determine the generic types.
-
parallel
public static <Type1,Type2> java.lang.Iterable<Pair<Type1,Type2>> parallel(java.lang.Iterable<Type1> iterable1, java.lang.Iterable<Type2> iterable2)
-
-