List of usage examples for java.util.function ToLongFunction applyAsLong
long applyAsLong(T value);
From source file:at.gridtec.lambda4j.operator.ternary.LongTernaryOperator.java
/** * Returns a composed {@link ToLongTriFunction} that first applies the {@code before} functions to its input, and * then applies this operator 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 operator is applied * @param before2 The second function to apply before this operator is applied * @param before3 The third function to apply before this operator is applied * @return A composed {@code ToLongTriFunction} that first applies the {@code before} functions to its input, and * then applies this operator 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 www .j a v a2s .c o m @Nonnull default <A, B, C> ToLongTriFunction<A, B, C> compose(@Nonnull final ToLongFunction<? super A> before1, @Nonnull final ToLongFunction<? super B> before2, @Nonnull final ToLongFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> applyAsLong(before1.applyAsLong(a), before2.applyAsLong(b), before3.applyAsLong(c)); }
From source file:at.gridtec.lambda4j.predicate.tri.TriLongPredicate.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 .j a v a 2s . c o m @Nonnull default <A, B, C> TriPredicate<A, B, C> compose(@Nonnull final ToLongFunction<? super A> before1, @Nonnull final ToLongFunction<? super B> before2, @Nonnull final ToLongFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> test(before1.applyAsLong(a), before2.applyAsLong(b), before3.applyAsLong(c)); }
From source file:at.gridtec.lambda4j.predicate.tri.obj.ObjBiLongPredicate.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 v a 2s . co m @Nonnull default <A, B, C> TriPredicate<A, B, C> compose(@Nonnull final Function<? super A, ? extends T> before1, @Nonnull final ToLongFunction<? super B> before2, @Nonnull final ToLongFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> test(before1.apply(a), before2.applyAsLong(b), before3.applyAsLong(c)); }
From source file:at.gridtec.lambda4j.predicate.tri.obj.BiObjLongPredicate.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 a v a 2 s . co m @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 ToLongFunction<? super C> before3) { Objects.requireNonNull(before1); Objects.requireNonNull(before2); Objects.requireNonNull(before3); return (a, b, c) -> test(before1.apply(a), before2.apply(b), before3.applyAsLong(c)); }
From source file:org.briljantframework.array.AbstractArray.java
@Override public LongArray mapToLong(ToLongFunction<? super T> f) { LongArray array = getArrayFactory().newLongArray(getShape()); for (int i = 0; i < size(); i++) { array.set(i, f.applyAsLong(get(i))); }//ww w . j av a 2 s .c o m return array; }
From source file:org.briljantframework.array.AbstractArray.java
@Override public LongArray asLong(ToLongFunction<? super T> to, LongFunction<T> from) { return new AsLongArray(getArrayFactory(), getOffset(), getShape(), getStride(), getMajorStrideIndex()) { @Override//from w ww . j a va2 s . c om protected void setElement(int i, long value) { AbstractArray.this.setElement(i, from.apply(value)); } @Override protected long getElement(int i) { return to.applyAsLong(AbstractArray.this.getElement(i)); } @Override protected int elementSize() { return AbstractArray.this.elementSize(); } }; }
From source file:org.briljantframework.array.AbstractComplexArray.java
@Override public LongArray mapToLong(ToLongFunction<Complex> function) { LongArray matrix = factory.newLongArray(getShape()); for (int i = 0; i < size(); i++) { matrix.set(i, function.applyAsLong(get(i))); }// www.j a v a2 s . c om return matrix; }
From source file:org.briljantframework.array.AbstractLongArray.java
@Override public LongArray assign(ComplexArray array, ToLongFunction<? super Complex> function) { array = ShapeUtils.broadcastIfSensible(this, array); Check.size(this, array); for (int i = 0; i < size(); i++) { set(i, function.applyAsLong(array.get(i))); }//from w ww . j a v a 2 s . c o m return this; }
From source file:org.briljantframework.array.AbstractLongArray.java
@Override public LongArray reduceVector(int dim, ToLongFunction<? super LongArray> accumulator) { Check.argument(dim < dims(), INVALID_DIMENSION, dim, dims()); LongArray reduced = newEmptyArray(ArrayUtils.remove(getShape(), dim)); int vectors = vectors(dim); for (int i = 0; i < vectors; i++) { long value = accumulator.applyAsLong(getVector(dim, i)); reduced.set(i, value);/*from w w w . j a v a2s . c o m*/ } return reduced; }
From source file:org.eclipse.packagedrone.utils.rpm.build.RpmBuilder.java
private static void putNumber(final LongMode longMode, final Header<RpmTag> header, final Collection<FileEntry> files, final RpmTag tag, final ToLongFunction<FileEntry> func) { boolean useLong; if (longMode == LongMode.FORCE_64BIT) { // no need to check, got with 64bit useLong = true;/*from ww w .ja v a 2 s . c o m*/ } else { // check if we need 64bit final boolean needLong = needLong(files, func); if (longMode == LongMode.FORCE_32BIT) { if (needLong) { // we need it but are forced to 32bit throw new IllegalStateException("Requested 32bit mode, but 64bit is necessary"); } else { // we don't need it, so we can accept 32bit useLong = false; } } else // everything else is DEFAULT { // we can choose, so choose useLong = needLong; } } if (useLong) { // write as 64bit Header.putLongFields(header, files, tag, func); } else { // write as 32bit Header.putIntFields(header, files, tag, file -> (int) func.applyAsLong(file)); } }