public class Choice extends Object
BitSet
to store the current choice.
If the choice is declared as exclusive (needed for oneOf
, for
instance), it is guaranteed that the bitset always has at most one set bit.
If the choice is non-exclusive (needed for anyOf
, for instance), the
bitset can have more than one set bit.
That is, if the choice is non-exclusive, it is possible to select multiple
possibilities at the same time.
It is possible to get the value in base 10 corresponding to the current
choice.Constructor and Description |
---|
Choice(int nPossibilities,
boolean exclusive)
Creates an exclusive or non-exclusive choice over the given number of
possibilities
|
Modifier and Type | Method and Description |
---|---|
int |
currentValue() |
BitSet |
getBitSet() |
boolean |
hasNextValue() |
boolean |
isExclusive() |
int |
nextValue() |
int |
numberOfValues() |
String |
toString() |
public Choice(int nPossibilities, boolean exclusive)
nPossibilities
- The number of possibilitiesexclusive
- Whether this choice is exclusive (i.e., whether each
possibility must be taken individually, or if we can
take multiple possibilities at the same time).public int numberOfValues()
public boolean hasNextValue()
public int nextValue()
public int currentValue()
public BitSet getBitSet()
public boolean isExclusive()
Copyright © 2022. All rights reserved.