java.lang.Object
org.maxicp.cp.engine.core.SparseSetDomain
- All Implemented Interfaces:
IntDomain
Implementation of a domain with a sparse-set
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(int v) Checks if the specified value belongs to the domain.intfillArray(int[] dest) Copies the values of the domain into an array.intfillDeltaArray(int oldMin, int oldMax, int oldSize, int[] arr) booleanChecks if the domain contains a single element.intmax()Returns the maximum value of the domain.intmin()Returns the minimum value of the domain.voidremove(int v, IntDomainListener l) Removes a value from the domain and notifies appropriately the listener.voidremoveAbove(int value, IntDomainListener l) Removes every value larger than the specified value from the domain.voidremoveAllBut(int v, IntDomainListener l) Removes every value from the domain except the specified one.voidremoveBelow(int value, IntDomainListener l) Removes every value less than the specified value from the domain.intsize()Returns the cardinality of the domain.toString()
-
Constructor Details
-
SparseSetDomain
-
-
Method Details
-
fillArray
public int fillArray(int[] dest) Description copied from interface:IntDomainCopies the values of the domain into an array. -
min
public int min()Description copied from interface:IntDomainReturns the minimum value of the domain. -
max
public int max()Description copied from interface:IntDomainReturns the maximum value of the domain. -
size
public int size()Description copied from interface:IntDomainReturns the cardinality of the domain. -
contains
public boolean contains(int v) Description copied from interface:IntDomainChecks if the specified value belongs to the domain. -
isSingleton
public boolean isSingleton()Description copied from interface:IntDomainChecks if the domain contains a single element.- Specified by:
isSingletonin interfaceIntDomain- Returns:
- true if the domain contains a single element, false otherwise
-
remove
Description copied from interface:IntDomainRemoves a value from the domain and notifies appropriately the listener.- Specified by:
removein interfaceIntDomain- Parameters:
v- the value to be removedl- the methods of the listener are notified as follows:-
IntDomainListener.change()is called if v belongs to the domain -
IntDomainListener.changeMax()is called if v is equal to the maximum value -
IntDomainListener.changeMin()is called if v is equal to the minimum value -
IntDomainListener.bind()is called if v belongs to the domain and after its removal the domain has a single value -
IntDomainListener.empty()is called if v is the last value in the domain i.e. the domain is empty after this operation
-
-
removeAllBut
Description copied from interface:IntDomainRemoves every value from the domain except the specified one.- Specified by:
removeAllButin interfaceIntDomain- Parameters:
v- the value to be keptl- the methods of the listener are notified as follows:-
IntDomainListener.change()is called if some value is removed during the operation -
IntDomainListener.changeMax()is called if v is not equal to the maximum value -
IntDomainListener.changeMin()is called if v is not equal to the minimum value -
IntDomainListener.bind()is called if v belongs to the domain and after its removal the domain has a single value -
IntDomainListener.empty()is called if v is not in the domain i.e. the domain is empty after this operation
-
-
removeBelow
Description copied from interface:IntDomainRemoves every value less than the specified value from the domain.- Specified by:
removeBelowin interfaceIntDomain- Parameters:
value- the value such that all the values less than v are removedl- the methods of the listener are notified as follows:-
IntDomainListener.change()is called if some value is removed during the operation -
IntDomainListener.changeMax()is called if v is is larger than the minimum value -
IntDomainListener.bind()is called if v is equal to the maximum value -
IntDomainListener.empty()is called if v is larger than the maximum value i.e. the domain is empty after this operation
-
-
removeAbove
Description copied from interface:IntDomainRemoves every value larger than the specified value from the domain.- Specified by:
removeAbovein interfaceIntDomain- Parameters:
value- the value such that all the values larger than v are removedl- the methods of the listener are notified as follows:-
IntDomainListener.change()is called if some value is removed during the operation -
IntDomainListener.changeMax()is called if v is is less than the maximum value -
IntDomainListener.bind()is called if v is equal to the minimum value -
IntDomainListener.empty()is called if v is less than the minimum value i.e. the domain is empty after this operation
-
-
toString
-
fillDeltaArray
public int fillDeltaArray(int oldMin, int oldMax, int oldSize, int[] arr) - Specified by:
fillDeltaArrayin interfaceIntDomain
-