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