Example usage for java.util.function DoublePredicate test

List of usage examples for java.util.function DoublePredicate test

Introduction

In this page you can find the example usage for java.util.function DoublePredicate test.

Prototype

boolean test(double value);

Source Link

Document

Evaluates this predicate on the given argument.

Usage

From source file:at.gridtec.lambda4j.predicate.tri.obj.BiObjBooleanPredicate.java

/**
 * Returns a composed {@link TriDoublePredicate} that first applies the {@code before} functions to its input, and
 * then applies this predicate to the result. If evaluation of either operation throws an exception, it is relayed
 * to the caller of the composed operation. This method is just convenience, to provide the ability to execute an
 * operation which accepts {@code double} input, before this primitive predicate is executed.
 *
 * @param before1 The first function to apply before this predicate is applied
 * @param before2 The second function to apply before this predicate is applied
 * @param before3 The third predicate to apply before this predicate is applied
 * @return A composed {@code TriDoublePredicate} that first applies the {@code before} functions to its input, and
 * then applies this predicate to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is a able to handle primitive values. In this case this is {@code
 * double}.//from   w  ww.  j av  a2  s .c  om
 */
@Nonnull
default TriDoublePredicate composeFromDouble(@Nonnull final DoubleFunction<? extends T> before1,
        @Nonnull final DoubleFunction<? extends U> before2, @Nonnull final DoublePredicate before3) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    Objects.requireNonNull(before3);
    return (value1, value2, value3) -> test(before1.apply(value1), before2.apply(value2), before3.test(value3));
}

From source file:org.briljantframework.array.AbstractDoubleArray.java

@Override
public DoubleArray filter(DoublePredicate predicate) {
    DoubleList builder = new DoubleList();
    for (int i = 0; i < size(); i++) {
        double value = get(i);
        if (predicate.test(value)) {
            builder.add(value);// w w w.j av  a 2s  . c o m
        }
    }
    return factory.newDoubleVector(Arrays.copyOf(builder.elementData, builder.size()));
}

From source file:org.briljantframework.array.AbstractDoubleArray.java

@Override
public BooleanArray where(DoublePredicate predicate) {
    BooleanArray bits = factory.newBooleanArray(getShape());
    for (int i = 0; i < size(); i++) {
        bits.set(i, predicate.test(get(i)));
    }//from  w  w  w.ja  v  a 2s.  c  o  m
    return bits;
}

From source file:org.briljantframework.array.Arrays.java

public static boolean any(DoubleArray array, DoublePredicate predicate) {
    for (int i = 0; i < array.size(); i++) {
        if (predicate.test(array.get(i))) {
            return true;
        }//w w  w .  j  a  va 2  s  . c  o  m
    }
    return false;
}