@FunctionalInterface
public interface VarLongOperator
Although this basically works for a variable long array
via the apply(long...)
method implementors
have to implement the method apply(LongIndexable)
with a LongIndexable
argument. This is done
to make this class generally more useful without the need
to copy arrays.
Modifier and Type | Method and Description |
---|---|
default long |
apply(long... values)
Apply this operator.
|
long |
apply(LongIndexable values)
Apply this operator.
|
static VarLongOperator |
fromBinary(java.util.function.LongBinaryOperator binaryOp,
long startValue)
Create an variable args operator from applying a binary operator
over and over.
|
default long apply(long... values)
apply(LongIndexable)
.values
- arguments on which this operator is appliedlong apply(@NotNull LongIndexable values)
values
- indexable providing the values on which this operator operates@NotNull static VarLongOperator fromBinary(@NotNull java.util.function.LongBinaryOperator binaryOp, long startValue)
Eg
On each application the currently accumulated result becomes the left (first) argument ofVarLongOperator maxOp = VarLongOperator.fromBinary(Math::max, Long.MIN_VALUE); long max = maxOp.apply(1L, -7L, -13L, 42L);
binaryOp
, while the run value becomes the right (second).binaryOp
- binary operatorstartValue
- start value (result of operator if no values are given)