Package org.nasengolem.util.zip
Class Zip2<V1,V2,I1 extends Iterable<V1>,I2 extends Iterable<V2>>
java.lang.Object
org.nasengolem.util.zip.Zip<org.jooq.lambda.tuple.Tuple2<V1,V2>>
org.nasengolem.util.zip.Zip2<V1,V2,I1,I2>
- Type Parameters:
V1
- the type of elements in the first iterable.V2
- the type of elements in the second iterable.I1
- the type of the first iterable, which must be anIterable<V1>
.I2
- the type of the second iterable, which must be anIterable<V2>
.
- All Implemented Interfaces:
Iterable<org.jooq.lambda.tuple.Tuple2<V1,
,V2>> Iterator<org.jooq.lambda.tuple.Tuple2<V1,
V2>>
public class Zip2<V1,V2,I1 extends Iterable<V1>,I2 extends Iterable<V2>>
extends Zip<org.jooq.lambda.tuple.Tuple2<V1,V2>>
The
Zip2
class combines two iterables into a single iterable of pairs (tuples).
It generates a sequence of Tuple2
objects, where each tuple contains one element from the
first iterable and one element from the second iterable. If the iterables are of different lengths,
the resulting sequence stops when the shorter iterable is exhausted.
This functionality is inspired by the zip
function in Python.
For more information on the Python equivalent,
see Python zip documentation.
Since Java does not natively support tuples or pattern matching, this implementation
uses tuples from the org.jooq.lambda.tuple
package to fill that gap.
- Author:
- Paul Steinbach
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
Zip2
-
-
Method Details
-
hasNext
public boolean hasNext()Returnstrue
if both iterables have more elements to iterate.- Returns:
true
if both iterables have remaining elements, otherwisefalse
.
-
next
-