choco.cp.solver.variables.set
Class BitSetEnumeratedDomain

java.lang.Object
  extended by choco.cp.solver.variables.set.BitSetEnumeratedDomain
All Implemented Interfaces:
IPretty, Domain, SetSubDomain

public class BitSetEnumeratedDomain
extends Object
implements SetSubDomain


Field Summary
protected  IStateBitSet contents
          A bit set indicating for each value whether it is present or not
protected  int offset
          The offset, that is the minimal value of the domain (stored at index 0).
protected  IStateInt size
          Number of present values.
 
Fields inherited from interface choco.kernel.solver.variables.set.SetSubDomain
LOGGER
 
Constructor Summary
BitSetEnumeratedDomain(SetVar v, int[] sortedValues, boolean full, IEnvironment environment)
           
BitSetEnumeratedDomain(SetVar v, int a, int b, boolean full, IEnvironment environment)
          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.
 IDeltaDomain copyDelta()
           
static BitSetEnumeratedDomain empty(SetVar v, IEnvironment environment)
          Specific constructor for empty set variable
 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
 DisposableIntIterator 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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 IStateInt size
Number of present values.


contents

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

Constructor Detail

BitSetEnumeratedDomain

public BitSetEnumeratedDomain(SetVar v,
                              int a,
                              int b,
                              boolean full,
                              IEnvironment environment)
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)
environment -

BitSetEnumeratedDomain

public BitSetEnumeratedDomain(SetVar v,
                              int[] sortedValues,
                              boolean full,
                              IEnvironment environment)
Method Detail

empty

public static BitSetEnumeratedDomain empty(SetVar v,
                                           IEnvironment environment)
Specific constructor for empty set variable

Parameters:
v - the set variable with no value
environment -
Returns:
empty BitSetEnumeratedDomain

getFirstVal

public int getFirstVal()
Returns the minimal present value.

Specified by:
getFirstVal in interface SetSubDomain

getLastVal

public int getLastVal()
Returns the maximal present value.

Specified by:
getLastVal in interface SetSubDomain

contains

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

Specified by:
contains in interface SetSubDomain
Parameters:
x - The value to check.

remove

public boolean remove(int x)
Removes a value.

Specified by:
remove in interface SetSubDomain

add

public boolean add(int x)
add a value.

Parameters:
x - value to add
Returns:
true wether the value has been added

getSize

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

Specified by:
getSize in interface SetSubDomain

getNextValue

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

Specified by:
getNextValue in interface SetSubDomain
Parameters:
x - starting value
Returns:
value following x

getPrevValue

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

Parameters:
x - starting value
Returns:
value preceding x

hasNextValue

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

Parameters:
x - starting value
Returns:
true whether there is a following value

hasPrevValue

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

Parameters:
x - starting value
Returns:
true if there is a preceding value

getDeltaIterator

public DisposableIntIterator getDeltaIterator()
Specified by:
getDeltaIterator in interface SetSubDomain

copyDelta

public IDeltaDomain copyDelta()
Specified by:
copyDelta in interface SetSubDomain

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 SetSubDomain

releaseDeltaDomain

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

Specified by:
releaseDeltaDomain in interface SetSubDomain
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()
Specified by:
getReleasedDeltaDomain in interface SetSubDomain

clearDeltaDomain

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

Specified by:
clearDeltaDomain in interface SetSubDomain

pretty

public String pretty()
pretty printing of the object. This String is not constant and may depend on the context.

Specified by:
pretty in interface IPretty
Returns:
a readable string representation of the object


Copyright © 2012. All Rights Reserved.