@FunctionalInterface
public interface VarCharOperator
Although this basically works for a variable char array
via the apply(char...)
method implementors
have to implement the method apply(CharIndexable)
with a CharIndexable
argument. This is done
to make this class generally more useful without the need
to copy arrays.
Modifier and Type | Method and Description |
---|---|
default char |
apply(char... values)
Apply this operator.
|
char |
apply(CharIndexable values)
Apply this operator.
|
static VarCharOperator |
fromBinary(CharOperator2 binaryOp,
char startValue)
Create an variable args operator from applying a binary operator
over and over.
|
default char apply(char... values)
apply(CharIndexable)
.values
- arguments on which this operator is appliedchar apply(@NotNull CharIndexable values)
values
- indexable providing the values on which this operator operates@NotNull static VarCharOperator fromBinary(@NotNull CharOperator2 binaryOp, char startValue)
Eg
VarCharOperator maxOp = VarCharOperator.fromBinary((v1, v2) -> (char)Math.max(v1, v2), '\0');
char max = maxOp.apply('A', 'B', 'C', 'D'');
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)