Class Domain
java.lang.Object
com.google.ortools.util.Domain
We call domain any subset of Int64 = [kint64min, kint64max].
 
This class can be used to represent such set efficiently as a sorted and
non-adjacent list of intervals. This is efficient as long as the size of such
list stays reasonable.
 
In the comments below, the domain of *this will always be written 'D'.
Note that all the functions are safe with respect to integer overflow.
This class can be used to represent such set efficiently as a sorted and
non-adjacent list of intervals. This is efficient as long as the size of such
list stays reasonable.
In the comments below, the domain of *this will always be written 'D'.
Note that all the functions are safe with respect to integer overflow.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionDomain()By default, Domain will be empty.Domain(long value) Constructor for the common case of a singleton domain.Domain(long cPtr, boolean cMemoryOwn) Domain(long left, long right) Constructor for the common case of a single interval [left, right].
 If left > right, this will result in the empty domain.
- 
Method SummaryModifier and TypeMethodDescriptionadditionWith(Domain domain) Returns {x ∈ Int64, ∃ a ∈ D, ∃ b ∈ domain, x = a + b}.static DomainReturns the full domain Int64.Returns the set Int64 ∖ D.booleancontains(long value) Returns true iff value is in Domain.voiddelete()protected voidfinalize()long[]This method returns the flattened list of interval bounds of the domain.
 
 Thus the domain {0, 1, 2, 5, 8, 9, 10} will return [0, 2, 5, 5,
 8, 10] (as a C++ std::vector<int64_t>, as a java or C# long[], as
 a python list of integers).static DomainfromFlatIntervals(long[] flat_intervals) This method is available in Python, Java and .NET.static DomainfromIntervals(long[][] intervals) This method is available in Python, Java and .NET.static DomainfromValues(long[] values) Creates a domain from the union of an unsorted list of integer values.
 Input values may be repeated, with no consequence on the outputstatic longintersectionWith(Domain domain) Returns the intersection of D and domain.booleanisEmpty()Returns true if this is the empty set.longmax()Returns the max value of the domain.
 The domain must not be empty.longmin()Returns the min value of the domain.
 The domain must not be empty.negation()Returns {x ∈ Int64, ∃ e ∈ D, x = -e}.
 
 Note in particular that if the negation of Int64 is not Int64 but
 Int64 \ {kint64min} !!longsize()Returns the number of elements in the domain.static longswigRelease(Domain obj) toString()Returns a compact string of a vector of intervals like "[1,4][6][10,20]".Returns the union of D and domain.
- 
Field Details- 
swigCMemOwnprotected transient boolean swigCMemOwn
 
- 
- 
Constructor Details- 
Domainpublic Domain(long cPtr, boolean cMemoryOwn) 
- 
Domainpublic Domain()By default, Domain will be empty.
- 
Domainpublic Domain(long value) Constructor for the common case of a singleton domain.
- 
Domainpublic Domain(long left, long right) Constructor for the common case of a single interval [left, right].
 If left > right, this will result in the empty domain.
 
- 
- 
Method Details- 
getCPtr
- 
swigRelease
- 
finalize
- 
deletepublic void delete()
- 
allValuesReturns the full domain Int64.
- 
fromValuesCreates a domain from the union of an unsorted list of integer values.
 Input values may be repeated, with no consequence on the output
- 
fromIntervalsThis method is available in Python, Java and .NET. It allows
 building a Domain object from a list of intervals (long[][] in Java and
 .NET, [[0, 2], [5], [8, 10]] in python).
 
 Note that the intervals can be defined with a single value (i.e. [5]), or
 two increasing values (i.e. [8, 10]).
 
 Invalid intervals (start > end) will log a DFATAL error and will be
 ignored.
- 
fromFlatIntervalsThis method is available in Python, Java and .NET. It allows
 building a Domain object from a flattened list of intervals
 (long[] in Java and .NET, [0, 2, 5, 5, 8, 10] in python).
 
 Note that invalid intervals (start > end) will log a DFATAL error and will
 be ignored.
- 
flattenedIntervalspublic long[] flattenedIntervals()This method returns the flattened list of interval bounds of the domain.
 
 Thus the domain {0, 1, 2, 5, 8, 9, 10} will return [0, 2, 5, 5,
 8, 10] (as a C++ std::vector<int64_t>, as a java or C# long[], as
 a python list of integers).
- 
isEmptypublic boolean isEmpty()Returns true if this is the empty set.
- 
sizepublic long size()Returns the number of elements in the domain. It is capped at kint64max
- 
minpublic long min()Returns the min value of the domain.
 The domain must not be empty.
- 
maxpublic long max()Returns the max value of the domain.
 The domain must not be empty.
- 
containspublic boolean contains(long value) Returns true iff value is in Domain.
- 
complementReturns the set Int64 ∖ D.
- 
negationReturns {x ∈ Int64, ∃ e ∈ D, x = -e}.
 
 Note in particular that if the negation of Int64 is not Int64 but
 Int64 \ {kint64min} !!
- 
intersectionWith
- 
unionWith
- 
additionWith
- 
toString
 
-