choco.cp.solver.variables.integer
Class BitSetIntDomain

java.lang.Object
  extended by choco.cp.solver.variables.integer.AbstractIntDomain
      extended by choco.cp.solver.variables.integer.BitSetIntDomain
All Implemented Interfaces:
IPretty, Domain, IBitSetIntDomain, IntDomain

public final class BitSetIntDomain
extends AbstractIntDomain
implements IBitSetIntDomain


Field Summary
protected  DisposableIntIterator _cachedDeltaIntDomainIterator
           
protected  BitSetIntDomainIterator _iterator
           
 
Fields inherited from class choco.cp.solver.variables.integer.AbstractIntDomain
currentInfPropagated, currentSupPropagated
 
Fields inherited from interface choco.kernel.solver.variables.integer.IntDomain
LOGGER
 
Constructor Summary
BitSetIntDomain(IntDomainVarImpl v, int[] sortedValues, IEnvironment environment, PropagationEngine propagationEngine)
           
BitSetIntDomain(IntDomainVarImpl v, int a, int b, IEnvironment environment, PropagationEngine propagationEngine)
          Constructs a new domain for the specified variable and bounds.
 
Method Summary
 boolean contains(int x)
          Checks if the value is present.
 int fastNextValue(int x)
          Accessing the smallest value stored in the domain and strictly greater than x, assuming x is greater or equal to the lower bound.
 IStateBitSet getContent()
           
 int getInf()
          Returns the minimal present value.
 DisposableIntIterator getIterator()
          Retrieve an getIterator for traversing the sequence of values contained in the domain
 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.
 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 isBoolean()
          Is it a 0/1 domain ?
 boolean isEnumerated()
           
 String pretty()
          pretty printing of the object.
 boolean remove(int x)
          Removes a value.
 void restrict(int x)
          Removes all the value but the specified one.
 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.cp.solver.variables.integer.AbstractIntDomain
clearDeltaDomain, copyDelta, fastPrevValue, freezeDeltaDomain, getDeltaIterator, getReleasedDeltaDomain, instantiate, releaseDeltaDomain, removeInterval, removeVal, updateInf, updateSup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_iterator

protected BitSetIntDomainIterator _iterator

_cachedDeltaIntDomainIterator

protected DisposableIntIterator _cachedDeltaIntDomainIterator
Constructor Detail

BitSetIntDomain

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

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

BitSetIntDomain

public BitSetIntDomain(IntDomainVarImpl v,
                       int[] sortedValues,
                       IEnvironment environment,
                       PropagationEngine propagationEngine)
Method Detail

getContent

public IStateBitSet getContent()
Specified by:
getContent in interface IBitSetIntDomain

getInf

public int getInf()
Returns the minimal present value.

Specified by:
getInf in interface IntDomain

getSup

public int getSup()
Returns the maximal present value.

Specified by:
getSup in interface IntDomain

updateInf

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

Specified by:
updateInf in interface IntDomain
Parameters:
x - New bound value.

updateSup

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

Specified by:
updateSup in interface IntDomain
Parameters:
x - New bound value.

contains

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

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

remove

public boolean remove(int x)
Removes a value.

Specified by:
remove in interface IntDomain

restrict

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

Specified by:
restrict in interface IntDomain

getSize

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

Specified by:
getSize in interface IntDomain

getIterator

public DisposableIntIterator getIterator()
Description copied from interface: IntDomain
Retrieve an getIterator for traversing the sequence of values contained in the domain

Specified by:
getIterator in interface IntDomain

getNextValue

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

Specified by:
getNextValue in interface IntDomain

fastNextValue

public final int fastNextValue(int x)
Description copied from interface: IntDomain
Accessing the smallest value stored in the domain and strictly greater than x, assuming x is greater or equal to the lower bound.

To iterate over the values in a IntDomain, use the following loop:

 int ub = dom.getSup();
 for (int val = dom.getInf(); val <= ub; val = dom.fastNextValue(val)) {
     // operate on value 'val' here
 }

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

getPrevValue

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

Specified by:
getPrevValue in interface IntDomain

hasNextValue

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

Specified by:
hasNextValue in interface IntDomain

hasPrevValue

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

Specified by:
hasPrevValue in interface IntDomain

getRandomValue

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

Specified by:
getRandomValue in interface IntDomain

isEnumerated

public boolean isEnumerated()
Specified by:
isEnumerated in interface IntDomain

isBoolean

public boolean isBoolean()
Description copied from interface: IntDomain
Is it a 0/1 domain ?

Specified by:
isBoolean in interface IntDomain

toString

public String toString()
Overrides:
toString in class AbstractIntDomain

pretty

public String pretty()
Description copied from interface: IPretty
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.