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