@FunctionalInterface
public interface VarFloatOperator
Although this basically works for a variable float array
via the apply(float...)
method implementors
have to implement the method apply(FloatIndexable)
with a FloatIndexable
argument. This is done
to make this class generally more useful without the need
to copy arrays.
Modifier and Type | Method and Description |
---|---|
default float |
apply(float... values)
Apply this operator.
|
float |
apply(FloatIndexable values)
Apply this operator.
|
static VarFloatOperator |
fromBinary(FloatOperator2 binaryOp,
float startValue)
Create an variable args operator from applying a binary operator
over and over.
|
default float apply(float... values)
apply(FloatIndexable)
.values
- arguments on which this operator is appliedfloat apply(@NotNull FloatIndexable values)
values
- indexable providing the values on which this operator operates@NotNull static VarFloatOperator fromBinary(@NotNull FloatOperator2 binaryOp, float startValue)
Eg
VarFloatOperator maxOp = VarFloatOperator.fromBinary((v1, v2) -> (float)Math.max(v1, v2), Float.NEGATIVE_INFINITY);
float max = maxOp.apply((1f, -7.1f, (float)Math.PI, 42f);
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)