@FunctionalInterface
public interface VarBooleanOperator
Although this basically works for a variable boolean array
via the apply(boolean...)
method implementors
have to implement the method apply(BooleanIndexable)
with a BooleanIndexable
argument. This is done
to make this class generally more useful without the need
to copy arrays.
Modifier and Type | Method and Description |
---|---|
default boolean |
apply(boolean... values)
Apply this operator.
|
boolean |
apply(BooleanIndexable values)
Apply this operator.
|
static VarBooleanOperator |
fromBinary(BooleanOperator2 binaryOp,
boolean startValue)
Create an variable args operator from applying a binary operator
over and over.
|
default boolean apply(boolean... values)
apply(BooleanIndexable)
.values
- arguments on which this operator is appliedboolean apply(@NotNull BooleanIndexable values)
values
- indexable providing the values on which this operator operates@NotNull static VarBooleanOperator fromBinary(@NotNull BooleanOperator2 binaryOp, boolean startValue)
Eg
VarBooleanOperator parityOp = VarBooleanOperator.fromBinary((b1, b2) -> b1 ^ b2, false);
boolean parity = parityOp.apply(true, false, false, true);
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)