com.jnape.palatable.lambda.functions.builtin.fn2.DropWhile 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.functions.builtin.fn2;
import com.jnape.palatable.lambda.functions.Fn1;
import com.jnape.palatable.lambda.functions.Fn2;
import com.jnape.palatable.lambda.iterators.PredicatedDroppingIterator;
import java.util.function.Function;
/**
* Lazily limit the Iterable
by skipping the first contiguous group of elements that satisfy the predicate,
* beginning iteration at the first element for which the predicate evaluates to false
.
*
* @param The Iterable element type
* @see Drop
* @see Filter
* @see TakeWhile
*/
public final class DropWhile implements Fn2, Iterable, Iterable> {
private DropWhile() {
}
@Override
public Iterable apply(Function super A, Boolean> predicate, Iterable as) {
return () -> new PredicatedDroppingIterator<>(predicate, as.iterator());
}
public static DropWhile dropWhile() {
return new DropWhile<>();
}
public static Fn1, Iterable> dropWhile(Function super A, Boolean> predicate) {
return DropWhile.dropWhile().apply(predicate);
}
public static Iterable dropWhile(Function super A, Boolean> predicate, Iterable as) {
return DropWhile.dropWhile(predicate).apply(as);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy