choco.integer.var
Class BitSetIntDomain

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.integer.var.AbstractIntDomain
          extended by choco.integer.var.BitSetIntDomain
All Implemented Interfaces:
Entity, IntDomain
Direct Known Subclasses:
JumpBitSetIntDomain, PalmBitSetIntDomain

public class BitSetIntDomain
extends AbstractIntDomain


Nested Class Summary
protected  class BitSetIntDomain.DeltaIntDomainIterator
           
 
Nested classes/interfaces inherited from class choco.integer.var.AbstractIntDomain
AbstractIntDomain.IntDomainIterator
 
Field Summary
protected  int capacity
          the initial size of the domain (never increases)
protected  int[] chain
          A chained list implementing two subsets of values: - the removed values waiting to be propagated - the removed values being propagated (each element points to the index of the enxt element) -1 for the last element
protected  StoredBitSet contents
          A bit set indicating for each value whether it is present or not
protected  int firstIndexBeingPropagated
          start of the chain for the values being propagated -1 for empty chains
protected  int firstIndexToBePropagated
          start of the chain for the values waiting to be propagated -1 for empty chains
protected  int offset
          The offset, that is the minimal value of the domain (stored at index 0).
protected static java.util.Random random
          A random generator for random value from the domain
protected  StoredInt size
          Number of present values.
 
Fields inherited from class choco.integer.var.AbstractIntDomain
currentInfPropagated, currentSupPropagated, logger, variable
 
Fields inherited from class choco.AbstractEntity
hook, problem
 
Constructor Summary
BitSetIntDomain(IntDomainVarImpl v, int[] sortedValues)
           
BitSetIntDomain(IntDomainVarImpl v, int a, int b)
          Constructs a new domain for the specified variable and bounds.
 
Method Summary
 void clearDeltaDomain()
          cleans the data structure implementing the delta domain
 boolean contains(int x)
          Checks if the value is present.
 void freezeDeltaDomain()
          The delta domain container is "frozen" (it can no longer accept new value removals) so that this set of values can be iterated as such
 IntIterator getDeltaIterator()
          Returns an getIterator over the set of values that have been removed from the domain since the last propagation
 int getInf()
          Returns the minimal present value.
 int getNextValue(int x)
          Returns the value following x
 int getPrevValue(int x)
          Returns the value preceding x
 int getRandomValue()
          Returns a value randomly choosed in the domain.
 boolean getReleasedDeltaDomain()
          checks whether the delta domain has indeed been released (ie: chechks that no domain updates are pending)
 int getSize()
          Returns the current size of the domain.
 int getSup()
          Returns the maximal present value.
 boolean hasNextValue(int x)
          Checks if the value has a following value.
 boolean hasPrevValue(int x)
          Checks if the value has a preceding value.
 boolean isEnumerated()
           
 java.lang.String pretty()
          pretty printing of the object.
 boolean releaseDeltaDomain()
          after an iteration over the delta domain, the delta domain is reopened again.
 boolean remove(int x)
          Removes a value.
 void restrict(int x)
          Removes all the value but the specified one.
 java.lang.String toString()
           
 int updateInf(int x)
          Sets a new minimal value.
 int updateSup(int x)
          Sets a new maximal value.
 
Methods inherited from class choco.integer.var.AbstractIntDomain
_instantiate, _removeVal, _updateInf, _updateSup, getIterator, instantiate, removeInterval, removeVal, updateInf, updateSup
 
Methods inherited from class choco.AbstractEntity
getProblem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface choco.Entity
getProblem
 

Field Detail

random

protected static java.util.Random random
A random generator for random value from the domain


offset

protected final int offset
The offset, that is the minimal value of the domain (stored at index 0). Thus the entry at index i corresponds to x=i+offset).


size

protected StoredInt size
Number of present values.


contents

protected StoredBitSet contents
A bit set indicating for each value whether it is present or not


capacity

protected int capacity
the initial size of the domain (never increases)


chain

protected int[] chain
A chained list implementing two subsets of values: - the removed values waiting to be propagated - the removed values being propagated (each element points to the index of the enxt element) -1 for the last element


firstIndexToBePropagated

protected int firstIndexToBePropagated
start of the chain for the values waiting to be propagated -1 for empty chains


firstIndexBeingPropagated

protected int firstIndexBeingPropagated
start of the chain for the values being propagated -1 for empty chains

Constructor Detail

BitSetIntDomain

public BitSetIntDomain(IntDomainVarImpl v,
                       int a,
                       int b)
Constructs a new domain for the specified variable and bounds.

Parameters:
v - The involved variable.
a - Minimal value.
b - Maximal value.

BitSetIntDomain

public BitSetIntDomain(IntDomainVarImpl v,
                       int[] sortedValues)
Method Detail

getInf

public int getInf()
Returns the minimal present value.


getSup

public int getSup()
Returns the maximal present value.


updateInf

public int updateInf(int x)
Sets a new minimal value.

Parameters:
x - New bound value.

updateSup

public int updateSup(int x)
Sets a new maximal value.

Parameters:
x - New bound value.

contains

public boolean contains(int x)
Checks if the value is present.

Parameters:
x - The value to check.

remove

public boolean remove(int x)
Removes a value.


restrict

public void restrict(int x)
Removes all the value but the specified one.


getSize

public int getSize()
Returns the current size of the domain.


getNextValue

public int getNextValue(int x)
Returns the value following x


getPrevValue

public int getPrevValue(int x)
Returns the value preceding x


hasNextValue

public boolean hasNextValue(int x)
Checks if the value has a following value.


hasPrevValue

public boolean hasPrevValue(int x)
Checks if the value has a preceding value.


getRandomValue

public int getRandomValue()
Returns a value randomly choosed in the domain.


isEnumerated

public boolean isEnumerated()

getDeltaIterator

public IntIterator getDeltaIterator()
Description copied from interface: IntDomain
Returns an getIterator over the set of values that have been removed from the domain since the last propagation


freezeDeltaDomain

public void freezeDeltaDomain()
The delta domain container is "frozen" (it can no longer accept new value removals) so that this set of values can be iterated as such

Specified by:
freezeDeltaDomain in interface IntDomain
Overrides:
freezeDeltaDomain in class AbstractIntDomain

releaseDeltaDomain

public boolean releaseDeltaDomain()
after an iteration over the delta domain, the delta domain is reopened again.

Specified by:
releaseDeltaDomain in interface IntDomain
Overrides:
releaseDeltaDomain in class AbstractIntDomain
Returns:
true iff the delta domain is reopened empty (no updates have been made to the domain while it was frozen, false iff the delta domain is reopened with pending value removals (updates were made to the domain, while the delta domain was frozen).

getReleasedDeltaDomain

public boolean getReleasedDeltaDomain()
Description copied from interface: IntDomain
checks whether the delta domain has indeed been released (ie: chechks that no domain updates are pending)

Specified by:
getReleasedDeltaDomain in interface IntDomain
Overrides:
getReleasedDeltaDomain in class AbstractIntDomain

clearDeltaDomain

public void clearDeltaDomain()
cleans the data structure implementing the delta domain

Specified by:
clearDeltaDomain in interface IntDomain
Overrides:
clearDeltaDomain in class AbstractIntDomain

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

pretty

public java.lang.String pretty()
Description copied from interface: Entity
pretty printing of the object. This String is not constant and may depend on the context.

Specified by:
pretty in interface Entity
Overrides:
pretty in class AbstractEntity
Returns:
a readable string representation of the object