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:Main.java

public static void main(String[] args) {
    DoublePredicate dp = (d) -> d > 0;

    System.out.println(dp.test(0.5));

}

From source file:Main.java

public static void main(String[] args) {
    DoublePredicate dp = (d) -> d > 0;

    System.out.println(dp.test(0.5));
    System.out.println(dp.negate().test(0.5));
}

From source file:gedi.util.datastructure.array.functions.NumericArrayFunction.java

public static NumericArrayFunction fraction(final DoublePredicate predicate) {
    return new NumericArrayFunction() {

        @Override/*w w  w  . ja va  2 s  .co  m*/
        public double applyAsDouble(NumericArray value) {
            int re = 0;
            for (int i = 0; i < value.length(); i++)
                if (predicate.test(value.getDouble(i)))
                    re++;
            return (double) re / value.length();
        }
    };
}

From source file:gedi.util.datastructure.array.functions.NumericArrayFunction.java

public static NumericArrayFunction count(final DoublePredicate predicate) {
    return new NumericArrayFunction() {

        @Override/*  w ww  .  j  av  a2  s . c  o m*/
        public double applyAsDouble(NumericArray value) {
            int re = 0;
            for (int i = 0; i < value.length(); i++)
                if (predicate.test(value.getDouble(i)))
                    re++;
            return re;
        }
    };
}

From source file:at.gridtec.lambda4j.predicate.bi.BiDoublePredicate.java

/**
 * Creates a {@link BiDoublePredicate} which uses the {@code first} parameter of this one as argument for the given
 * {@link DoublePredicate}./*  ww w .  jav  a 2 s. com*/
 *
 * @param predicate The predicate which accepts the {@code first} parameter of this one
 * @return Creates a {@code BiDoublePredicate} which uses the {@code first} parameter of this one as argument for
 * the given {@code DoublePredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static BiDoublePredicate onlyFirst(@Nonnull final DoublePredicate predicate) {
    Objects.requireNonNull(predicate);
    return (value1, value2) -> predicate.test(value1);
}

From source file:at.gridtec.lambda4j.predicate.bi.BiDoublePredicate.java

/**
 * Creates a {@link BiDoublePredicate} which uses the {@code second} parameter of this one as argument for the given
 * {@link DoublePredicate}.//from  w ww. j  a  v a2 s .  co m
 *
 * @param predicate The predicate which accepts the {@code second} parameter of this one
 * @return Creates a {@code BiDoublePredicate} which uses the {@code second} parameter of this one as argument for
 * the given {@code DoublePredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static BiDoublePredicate onlySecond(@Nonnull final DoublePredicate predicate) {
    Objects.requireNonNull(predicate);
    return (value1, value2) -> predicate.test(value2);
}

From source file:at.gridtec.lambda4j.predicate.bi.obj.ObjDoublePredicate.java

/**
 * Creates a {@link ObjDoublePredicate} which uses the {@code second} parameter of this one as argument for the
 * given {@link DoublePredicate}.//w ww. j  av  a2s .  c o  m
 *
 * @param <T> The type of the first argument to the predicate
 * @param predicate The predicate which accepts the {@code second} parameter of this one
 * @return Creates a {@code ObjDoublePredicate} which uses the {@code second} parameter of this one as argument for
 * the given {@code DoublePredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T> ObjDoublePredicate<T> onlySecond(@Nonnull final DoublePredicate predicate) {
    Objects.requireNonNull(predicate);
    return (t, value) -> predicate.test(value);
}

From source file:at.gridtec.lambda4j.predicate.tri.TriDoublePredicate.java

/**
 * Creates a {@link TriDoublePredicate} which uses the {@code first} parameter of this one as argument for the given
 * {@link DoublePredicate}./*from   w w w  .  j  a v  a 2 s.  com*/
 *
 * @param predicate The predicate which accepts the {@code first} parameter of this one
 * @return Creates a {@code TriDoublePredicate} which uses the {@code first} parameter of this one as argument for
 * the given {@code DoublePredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static TriDoublePredicate onlyFirst(@Nonnull final DoublePredicate predicate) {
    Objects.requireNonNull(predicate);
    return (value1, value2, value3) -> predicate.test(value1);
}

From source file:at.gridtec.lambda4j.predicate.tri.TriDoublePredicate.java

/**
 * Creates a {@link TriDoublePredicate} which uses the {@code second} parameter of this one as argument for the
 * given {@link DoublePredicate}./*from w w w . ja v  a 2s . co m*/
 *
 * @param predicate The predicate which accepts the {@code second} parameter of this one
 * @return Creates a {@code TriDoublePredicate} which uses the {@code second} parameter of this one as argument for
 * the given {@code DoublePredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static TriDoublePredicate onlySecond(@Nonnull final DoublePredicate predicate) {
    Objects.requireNonNull(predicate);
    return (value1, value2, value3) -> predicate.test(value2);
}

From source file:at.gridtec.lambda4j.predicate.tri.TriDoublePredicate.java

/**
 * Creates a {@link TriDoublePredicate} which uses the {@code third} parameter of this one as argument for the given
 * {@link DoublePredicate}.//from w w  w.  j  av a 2s.co  m
 *
 * @param predicate The predicate which accepts the {@code third} parameter of this one
 * @return Creates a {@code TriDoublePredicate} which uses the {@code third} parameter of this one as argument for
 * the given {@code DoublePredicate}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static TriDoublePredicate onlyThird(@Nonnull final DoublePredicate predicate) {
    Objects.requireNonNull(predicate);
    return (value1, value2, value3) -> predicate.test(value3);
}