com.jnape.palatable.lambda.functions.builtin.fn2.Drop 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.DroppingIterator;
/**
* Lazily skip the first n
elements from an Iterable
by returning an Iterable
* that begins iteration after the nth
element. If n
is greater than or equal to the length of
* the Iterable
, an empty Iterable
is returned.
*
* @param The Iterable element type
* @see DropWhile
* @see Take
*/
public final class Drop implements Fn2, Iterable> {
private Drop() {
}
@Override
public Iterable apply(Integer n, Iterable as) {
return () -> new DroppingIterator<>(n, as.iterator());
}
public static Drop drop() {
return new Drop<>();
}
public static Fn1, Iterable> drop(int n) {
return Drop.drop().apply(n);
}
public static Iterable drop(int n, Iterable as) {
return Drop.drop(n).apply(as);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy