All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jnape.palatable.lambda.functions.builtin.fn2.DropWhile Maven / Gradle / Ivy

There is a newer version: 5.5.0
Show newest version
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 predicate, Iterable as) {
        return () -> new PredicatedDroppingIterator<>(predicate, as.iterator());
    }

    public static  DropWhile dropWhile() {
        return new DropWhile<>();
    }

    public static  Fn1, Iterable> dropWhile(Function predicate) {
        return DropWhile.dropWhile().apply(predicate);
    }

    public static  Iterable dropWhile(Function predicate, Iterable as) {
        return DropWhile.dropWhile(predicate).apply(as);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy