List of usage examples for java.util.function ToIntFunction applyAsInt
int applyAsInt(T value);
From source file:at.gridtec.lambda4j.function.tri.obj.ObjBiIntToDoubleFunction.java
/** * Returns a composed {@link ToDoubleTriFunction} that first applies the {@code before} functions to its input, and * then applies this function to the result. * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation. * * @param <A> The type of the argument to the first given function, and of composed function * @param <B> The type of the argument to the second given function, and of composed function * @param <C> The type of the argument to the third given function, and of composed function * @param before1 The first function to apply before this function is applied * @param before2 The second function to apply before this function is applied * @param before3 The third function to apply before this function is applied * @return A composed {@code ToDoubleTriFunction} that first applies the {@code before} functions to its input, and * then applies this function to the result. * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is able to handle every type. *//*from w w w . j a va 2s . co m*/ @Nonnull default <A, B, C> ToDoubleTriFunction<A, B, C> compose(@Nonnull final Function<? super A, ? extends T> before1, @Nonnull final ToIntFunction<? super B> before2, @Nonnull final ToIntFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> applyAsDouble(before1.apply(a), before2.applyAsInt(b), before3.applyAsInt(c)); }
From source file:at.gridtec.lambda4j.function.tri.obj.BiObjIntToDoubleFunction.java
/** * Returns a composed {@link ToDoubleTriFunction} that first applies the {@code before} functions to its input, and * then applies this function to the result. * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation. * * @param <A> The type of the argument to the first given function, and of composed function * @param <B> The type of the argument to the second given function, and of composed function * @param <C> The type of the argument to the third given function, and of composed function * @param before1 The first function to apply before this function is applied * @param before2 The second function to apply before this function is applied * @param before3 The third function to apply before this function is applied * @return A composed {@code ToDoubleTriFunction} that first applies the {@code before} functions to its input, and * then applies this function to the result. * @throws NullPointerException If given argument is {@code null} * @implSpec The input argument of this method is able to handle every type. */// ww w. jav a 2s . co m @Nonnull default <A, B, C> ToDoubleTriFunction<A, B, C> compose(@Nonnull final Function<? super A, ? extends T> before1, @Nonnull final Function<? super B, ? extends U> before2, @Nonnull final ToIntFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> applyAsDouble(before1.apply(a), before2.apply(b), before3.applyAsInt(c)); }
From source file:at.gridtec.lambda4j.predicate.tri.TriIntPredicate.java
/** * Returns a composed {@link TriPredicate} 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. * * @param <A> The type of the argument to the first given function, and of composed predicate * @param <B> The type of the argument to the second given function, and of composed predicate * @param <C> The type of the argument to the third given function, and of composed predicate * @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 function to apply before this predicate is applied * @return A composed {@code TriPredicate} 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 able to handle every type. */// w w w . jav a 2 s. c o m @Nonnull default <A, B, C> TriPredicate<A, B, C> compose(@Nonnull final ToIntFunction<? super A> before1, @Nonnull final ToIntFunction<? super B> before2, @Nonnull final ToIntFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> test(before1.applyAsInt(a), before2.applyAsInt(b), before3.applyAsInt(c)); }
From source file:at.gridtec.lambda4j.predicate.tri.obj.ObjBiIntPredicate.java
/** * Returns a composed {@link TriPredicate} 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. * * @param <A> The type of the argument to the first given function, and of composed predicate * @param <B> The type of the argument to the second given function, and of composed predicate * @param <C> The type of the argument to the third given function, and of composed predicate * @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 function to apply before this predicate is applied * @return A composed {@code TriPredicate} 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 able to handle every type. *//*from w w w. j av a 2 s .c o m*/ @Nonnull default <A, B, C> TriPredicate<A, B, C> compose(@Nonnull final Function<? super A, ? extends T> before1, @Nonnull final ToIntFunction<? super B> before2, @Nonnull final ToIntFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> test(before1.apply(a), before2.applyAsInt(b), before3.applyAsInt(c)); }
From source file:at.gridtec.lambda4j.predicate.tri.obj.BiObjIntPredicate.java
/** * Returns a composed {@link TriPredicate} 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. * * @param <A> The type of the argument to the first given function, and of composed predicate * @param <B> The type of the argument to the second given function, and of composed predicate * @param <C> The type of the argument to the third given function, and of composed predicate * @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 function to apply before this predicate is applied * @return A composed {@code TriPredicate} 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 able to handle every type. *//*from w w w . ja va 2 s .com*/ @Nonnull default <A, B, C> TriPredicate<A, B, C> compose(@Nonnull final Function<? super A, ? extends T> before1, @Nonnull final Function<? super B, ? extends U> before2, @Nonnull final ToIntFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> test(before1.apply(a), before2.apply(b), before3.applyAsInt(c)); }
From source file:org.briljantframework.array.AbstractArray.java
@Override public IntArray mapToInt(ToIntFunction<? super T> f) { IntArray array = getArrayFactory().newIntArray(getShape()); for (int i = 0; i < size(); i++) { array.set(i, f.applyAsInt(get(i))); }//from w w w . j av a2 s . co m return array; }
From source file:org.briljantframework.array.AbstractArray.java
@Override public IntArray asInt(ToIntFunction<? super T> to, IntFunction<T> from) { return new AsIntArray(getArrayFactory(), getOffset(), getShape(), getStride(), getMajorStrideIndex()) { @Override/*from w w w.ja v a 2 s .c o m*/ protected void setElement(int i, int value) { AbstractArray.this.setElement(i, from.apply(value)); } @Override protected int getElement(int i) { return to.applyAsInt(AbstractArray.this.getElement(i)); } @Override protected int elementSize() { return AbstractArray.this.elementSize(); } }; }
From source file:org.briljantframework.array.AbstractComplexArray.java
@Override public IntArray mapToInt(ToIntFunction<Complex> function) { IntArray matrix = factory.newIntArray(getShape()); for (int i = 0; i < size(); i++) { matrix.set(i, function.applyAsInt(get(i))); }//from ww w. j a v a 2s. c om return matrix; }
From source file:org.briljantframework.array.AbstractIntArray.java
@Override public void assign(ComplexArray array, ToIntFunction<? super Complex> function) { array = ShapeUtils.broadcastIfSensible(this, array); Check.size(this, array); for (int i = 0; i < size(); i++) { set(i, function.applyAsInt(array.get(i))); }//from w ww.j a v a 2s. c o m }
From source file:org.briljantframework.array.AbstractIntArray.java
@Override public IntArray reduceVectors(int dim, ToIntFunction<? super IntArray> accumulator) { Check.argument(dim < dims(), INVALID_DIMENSION, dim, dims()); IntArray reduced = newEmptyArray(ArrayUtils.remove(getShape(), dim)); int vectors = vectors(dim); for (int i = 0; i < vectors; i++) { int value = accumulator.applyAsInt(getVector(dim, i)); reduced.set(i, value);//w ww .j a v a2s.co m } return reduced; }