Package org.projog.clp
Class VariableState
java.lang.Object
org.projog.clp.VariableState
Represents the possible values for a variable.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate NumberSetThe set of all possible values for thisVariableState.private static final NumberSetUsed to indicate aVariableStatehas become corrupt.private longThe maximum possible value for thisVariableState.private longThe minimum possible value for thisVariableState. -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates aVariableStatewith the full range of possible values.privateVariableState(long min, long max, NumberSet bitset) privateVariableState(VariableState original) -
Method Summary
Modifier and TypeMethodDescriptionstatic VariableStateand(VariableState a, VariableState b) Return the result of performing a logical "and" on the two givenVariableStates.copy()longcount()private VariableStateResultfail()longgetMax()longgetMin()booleanbooleanprivate static longmax(VariableState a, VariableState b) private static longmin(VariableState a, VariableState b) setMax(long max) setMin(long min) setNot(long not) setValue(long value) private static NumberSetsquashBitSet(VariableState s, long newMin, long newMax) private static VariableStatesquashVariableState(VariableState s, long newMin, long newMax) toString()private voidvalidate()
-
Field Details
-
CORRUPT
Used to indicate aVariableStatehas become corrupt.If
bitsetis assigned toCORRUPTthen that indicates theVariableStatehas become corrupt and should no longer be used.For example, a
VariableStatewould become corrupt if it had a minimum value of 7 and an attempt was made to set its maximum value to 6. -
min
private long minThe minimum possible value for thisVariableState. -
max
private long maxThe maximum possible value for thisVariableState. -
bitset
The set of all possible values for thisVariableState.If
nullthen indicates that all numbers in the rangemintomax(inclusive) are possible values for thisVariableState.If assigned to
CORRUPTthen indicates that thisVariableStatehas become corrupt and should no longer be used.
-
-
Constructor Details
-
VariableState
public VariableState()Creates aVariableStatewith the full range of possible values. -
VariableState
-
VariableState
-
-
Method Details
-
and
Return the result of performing a logical "and" on the two givenVariableStates.- Returns:
- a state representing a logical "and" of
aandb, ornullif no values shared between them
-
min
-
max
-
squashVariableState
-
squashBitSet
-
getMin
public long getMin() -
getMax
public long getMax() -
setValue
-
setMin
-
setMax
-
setNot
-
copy
-
count
public long count() -
getPossibilities
-
fail
-
validate
private void validate() -
isSingleValue
public boolean isSingleValue() -
isCorrupt
public boolean isCorrupt() -
toString
-