com.jnape.palatable.lambda.iterators.ZippingIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lambda Show documentation
Show all versions of lambda Show documentation
Functional patterns for Java
package com.jnape.palatable.lambda.iterators;
import java.util.Iterator;
import java.util.function.BiFunction;
public class ZippingIterator extends ImmutableIterator {
private final BiFunction super A, ? super B, ? extends C> zipper;
private final Iterator asIterator;
private final Iterator bsIterator;
public ZippingIterator(BiFunction super A, ? super B, ? extends C> zipper, Iterator asIterator,
Iterator bsIterator) {
this.asIterator = asIterator;
this.bsIterator = bsIterator;
this.zipper = zipper;
}
@Override
public boolean hasNext() {
return asIterator.hasNext() && bsIterator.hasNext();
}
@Override
public C next() {
return zipper.apply(asIterator.next(), bsIterator.next());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy