choco.set.var
Class BitSetEnumeratedDomain

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.set.var.BitSetEnumeratedDomain
All Implemented Interfaces:
Entity

public class BitSetEnumeratedDomain
extends AbstractEntity

Created by IntelliJ IDEA. User: Hadrien Date: 6 juin 2004 Time: 14:45:44 To change this template use File | Settings | File Templates.


Nested Class Summary
protected  class BitSetEnumeratedDomain.DeltaDomainIterator
           
 
Field Summary
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 static java.util.logging.Logger logger
           
protected  int offset
          The offset, that is the minimal value of the domain (stored at index 0).
protected  StoredInt size
          Number of present values.
 
Fields inherited from class choco.AbstractEntity
hook, problem
 
Constructor Summary
BitSetEnumeratedDomain(SetVar v, int a, int b, boolean full)
          Constructs a new domain for the specified variable and bounds.
 
Method Summary
 boolean add(int x)
          add a value.
 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()
           
 int getFirstVal()
          Returns the minimal present value.
 int getLastVal()
          Returns the maximal present value.
 int getNextValue(int x)
          Returns the value following x if non exist return -1
 int getPrevValue(int x)
          Returns the value preceding x if non exist return -1
 boolean getReleasedDeltaDomain()
           
 int getSize()
          Returns the current size of the domain.
 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 releaseDeltaDomain()
          after an iteration over the delta domain, the delta domain is reopened again.
 boolean remove(int x)
          Removes a value.
 
Methods inherited from class choco.AbstractEntity
getProblem, pretty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final java.util.logging.Logger logger

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


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

BitSetEnumeratedDomain

public BitSetEnumeratedDomain(SetVar v,
                              int a,
                              int b,
                              boolean full)
Constructs a new domain for the specified variable and bounds.

Parameters:
v - The involved variable.
a - Minimal value.
b - Maximal value.
full - indicate if the initial bitSetDomain is full or empty (env or ker)
Method Detail

getFirstVal

public int getFirstVal()
Returns the minimal present value.


getLastVal

public int getLastVal()
Returns the maximal present 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.


add

public boolean add(int x)
add a value.


getSize

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


getNextValue

public int getNextValue(int x)
Returns the value following x if non exist return -1


getPrevValue

public int getPrevValue(int x)
Returns the value preceding x if non exist return -1


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.


getDeltaIterator

public IntIterator getDeltaIterator()

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


releaseDeltaDomain

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

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()

clearDeltaDomain

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