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