- All Known Implementing Classes:
SparseSetDomain
public interface IntDomain
Interface for integer domain implementation.
A domain is encapsulated in an
CPIntVar implementation.
A domain is like a set of integers.-
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 v, 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 v, IntDomainListener l) Removes every value less than the specified value from the domain.intsize()Returns the cardinality of the domain.toString()
-
Method Details
-
min
int min()Returns the minimum value of the domain.- Returns:
- the minimum value of the domain
-
max
int max()Returns the maximum value of the domain.- Returns:
- the maximum value of the domain
-
size
int size()Returns the cardinality of the domain.- Returns:
- the cardinality value of the domain
-
contains
boolean contains(int v) Checks if the specified value belongs to the domain.- Parameters:
v- the value to be tested- Returns:
- true if v belongs to the domain, false otherwise
-
isSingleton
boolean isSingleton()Checks if the domain contains a single element.- Returns:
- true if the domain contains a single element, false otherwise
-
remove
Removes a value from the domain and notifies appropriately the listener.- 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
Removes every value from the domain except the specified one.- 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
Removes every value less than the specified value from the domain.- Parameters:
v- 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
Removes every value larger than the specified value from the domain.- Parameters:
v- 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
-
-
fillArray
int fillArray(int[] dest) Copies the values of the domain into an array.- Parameters:
dest- an array large enoughdest.length >= size()- Returns:
- the size of the domain and
dest[0,...,size-1]contains the values in the domain in an arbitrary order
-
fillDeltaArray
int fillDeltaArray(int oldMin, int oldMax, int oldSize, int[] arr) -
toString
String toString()
-