Package org.xcsp.common.domains
Class Domains.Dom
- java.lang.Object
-
- org.xcsp.common.domains.Domains.DomBasic
-
- org.xcsp.common.domains.Domains.Dom
-
- All Implemented Interfaces:
Domains.IDom
- Enclosing class:
- Domains
public static final class Domains.Dom extends Domains.DomBasic
The class for representing the domain of an integer variable.
-
-
Field Summary
-
Fields inherited from class org.xcsp.common.domains.Domains.DomBasic
values
-
-
Constructor Summary
Constructors Modifier Constructor Description Dom(int[] values)
Builds an integer domain, with the specified integer values.Dom(int min, int max)
Builds an integer domain, with the specified integer interval.protected
Dom(String seq)
Builds an integer domain, with the integer values (entities that are either integers or integer intervals) obtained by parsing the specified string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
allValues()
Returns the values of the integer domain, either as an object Range or as an array of integers.static String
compactFormOf(int[] values)
boolean
contains(long v)
Returns true iff the domain contains the specified value.long
firstValue()
Returns the first (smallest) value of the domain.long
lastValue()
Returns the last (greatest) value of the domain.long
nValues()
Returns the number of values in the domain, if the domain is finite.Domains.Dom
when(boolean condition)
Returns this object if the condition is evaluated totrue
,null
otherwise.-
Methods inherited from class org.xcsp.common.domains.Domains.DomBasic
parse, toString
-
-
-
-
Constructor Detail
-
Dom
protected Dom(String seq)
Builds an integer domain, with the integer values (entities that are either integers or integer intervals) obtained by parsing the specified string.
-
Dom
public Dom(int[] values)
Builds an integer domain, with the specified integer values.
-
Dom
public Dom(int min, int max)
Builds an integer domain, with the specified integer interval.
-
-
Method Detail
-
compactFormOf
public static String compactFormOf(int[] values)
-
firstValue
public long firstValue()
Returns the first (smallest) value of the domain. It may be VAL_M_INFINITY for -infinity.
-
lastValue
public long lastValue()
Returns the last (greatest) value of the domain. It may be VAL_P_INFINITY for +infinity.
-
contains
public boolean contains(long v)
Returns true iff the domain contains the specified value.
-
nValues
public long nValues()
Returns the number of values in the domain, if the domain is finite. Returns -1 otherwise.
-
allValues
public Object allValues()
Returns the values of the integer domain, either as an object Range or as an array of integers. Returns null if the domain is infinite (or too large).
-
when
public Domains.Dom when(boolean condition)
Returns this object if the condition is evaluated totrue
,null
otherwise.- Parameters:
condition
- a Boolean expression- Returns:
- this object if the condition is evaluated to
true
,null
otherwise
-
-