Package org.projog.clp
Class VariableState
- java.lang.Object
-
- org.projog.clp.VariableState
-
public final class VariableState extends java.lang.ObjectRepresents the possible values for a variable.
-
-
Field Summary
Fields Modifier and Type Field Description private NumberSetbitsetThe set of all possible values for thisVariableState.private static NumberSetCORRUPTUsed to indicate aVariableStatehas become corrupt.private longmaxThe maximum possible value for thisVariableState.private longminThe minimum possible value for thisVariableState.
-
Constructor Summary
Constructors Modifier Constructor Description VariableState()Creates aVariableStatewith the full range of possible values.privateVariableState(long min, long max, NumberSet bitset)privateVariableState(VariableState original)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static VariableStateand(VariableState a, VariableState b)Return the result of performing a logical "and" on the two givenVariableStates.VariableStatecopy()longcount()private VariableStateResultfail()longgetMax()longgetMin()PossibilitiesgetPossibilities()booleanisCorrupt()booleanisSingleValue()private static longmax(VariableState a, VariableState b)private static longmin(VariableState a, VariableState b)VariableStateResultsetMax(long max)VariableStateResultsetMin(long min)VariableStateResultsetNot(long not)VariableStateResultsetValue(long value)private static NumberSetsquashBitSet(VariableState s, long newMin, long newMax)private static VariableStatesquashVariableState(VariableState s, long newMin, long newMax)java.lang.StringtoString()private voidvalidate()
-
-
-
Field Detail
-
CORRUPT
private static final NumberSet 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 min
The minimum possible value for thisVariableState.
-
max
private long max
The maximum possible value for thisVariableState.
-
bitset
private NumberSet 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 Detail
-
VariableState
public VariableState()
Creates aVariableStatewith the full range of possible values.
-
VariableState
private VariableState(long min, long max, NumberSet bitset)
-
VariableState
private VariableState(VariableState original)
-
-
Method Detail
-
and
public static VariableState and(VariableState a, VariableState b)
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
private static long min(VariableState a, VariableState b)
-
max
private static long max(VariableState a, VariableState b)
-
squashVariableState
private static VariableState squashVariableState(VariableState s, long newMin, long newMax)
-
squashBitSet
private static NumberSet squashBitSet(VariableState s, long newMin, long newMax)
-
getMin
public long getMin()
-
getMax
public long getMax()
-
setValue
public VariableStateResult setValue(long value)
-
setMin
public VariableStateResult setMin(long min)
-
setMax
public VariableStateResult setMax(long max)
-
setNot
public VariableStateResult setNot(long not)
-
copy
public VariableState copy()
-
count
public long count()
-
getPossibilities
public Possibilities getPossibilities()
-
fail
private VariableStateResult fail()
-
validate
private void validate()
-
isSingleValue
public boolean isSingleValue()
-
isCorrupt
public boolean isCorrupt()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-