Google OR-Tools v9.9
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
com.google.ortools.util.Domain Class Reference

Public Member Functions

 Domain (long cPtr, boolean cMemoryOwn)
 
synchronized void delete ()
 
 Domain ()
 
 Domain (long value)
 
 Domain (long left, long right)
 
long[] flattenedIntervals ()
 
boolean isEmpty ()
 
long size ()
 
long min ()
 
long max ()
 
boolean contains (long value)
 
Domain complement ()
 
Domain negation ()
 
Domain intersectionWith (Domain domain)
 
Domain unionWith (Domain domain)
 
Domain additionWith (Domain domain)
 
String toString ()
 

Static Public Member Functions

static long getCPtr (Domain obj)
 
static long swigRelease (Domain obj)
 
static Domain allValues ()
 
static Domain fromValues (long[] values)
 
static Domain fromIntervals (long[][] intervals)
 
static Domain fromFlatIntervals (long[] flat_intervals)
 

Protected Member Functions

void finalize ()
 

Protected Attributes

transient boolean swigCMemOwn
 

Detailed Description

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.

Definition at line 21 of file Domain.java.

Constructor & Destructor Documentation

◆ Domain() [1/4]

com.google.ortools.util.Domain.Domain ( long cPtr,
boolean cMemoryOwn )

Definition at line 25 of file Domain.java.

◆ Domain() [2/4]

com.google.ortools.util.Domain.Domain ( )

By default, Domain will be empty.

Definition at line 64 of file Domain.java.

◆ Domain() [3/4]

com.google.ortools.util.Domain.Domain ( long value)

Constructor for the common case of a singleton domain.

Definition at line 71 of file Domain.java.

◆ Domain() [4/4]

com.google.ortools.util.Domain.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.

Definition at line 79 of file Domain.java.

Member Function Documentation

◆ additionWith()

Domain com.google.ortools.util.Domain.additionWith ( Domain domain)

Returns {x ∈ Int64, ∃ a ∈ D, ∃ b ∈ domain, x = a + b}.

Definition at line 198 of file Domain.java.

◆ allValues()

static Domain com.google.ortools.util.Domain.allValues ( )
static

Returns the full domain Int64.

Definition at line 86 of file Domain.java.

◆ complement()

Domain com.google.ortools.util.Domain.complement ( )

Returns the set Int64 ∖ D.

Definition at line 167 of file Domain.java.

◆ contains()

boolean com.google.ortools.util.Domain.contains ( long value)

Returns true iff value is in Domain.

Definition at line 160 of file Domain.java.

◆ delete()

synchronized void com.google.ortools.util.Domain.delete ( )

Definition at line 51 of file Domain.java.

◆ finalize()

void com.google.ortools.util.Domain.finalize ( )
protected

Definition at line 47 of file Domain.java.

◆ flattenedIntervals()

long[] com.google.ortools.util.Domain.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).

Definition at line 123 of file Domain.java.

◆ fromFlatIntervals()

static Domain com.google.ortools.util.Domain.fromFlatIntervals ( long[] flat_intervals)
static

This 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).

Definition at line 112 of file Domain.java.

◆ fromIntervals()

static Domain com.google.ortools.util.Domain.fromIntervals ( long intervals[][])
static

This 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, 5], [8, 10]] in python).

Definition at line 103 of file Domain.java.

◆ fromValues()

static Domain com.google.ortools.util.Domain.fromValues ( long[] values)
static

Creates a domain from the union of an unsorted list of integer values.
Input values may be repeated, with no consequence on the output

Definition at line 94 of file Domain.java.

◆ getCPtr()

static long com.google.ortools.util.Domain.getCPtr ( Domain obj)
static

Definition at line 30 of file Domain.java.

◆ intersectionWith()

Domain com.google.ortools.util.Domain.intersectionWith ( Domain domain)

Returns the intersection of D and domain.

Definition at line 184 of file Domain.java.

◆ isEmpty()

boolean com.google.ortools.util.Domain.isEmpty ( )

Returns true if this is the empty set.

Definition at line 130 of file Domain.java.

◆ max()

long com.google.ortools.util.Domain.max ( )

Returns the max value of the domain.
The domain must not be empty.

Definition at line 153 of file Domain.java.

◆ min()

long com.google.ortools.util.Domain.min ( )

Returns the min value of the domain.
The domain must not be empty.

Definition at line 145 of file Domain.java.

◆ negation()

Domain com.google.ortools.util.Domain.negation ( )

Returns {x ∈ Int64, ∃ e ∈ D, x = -e}.

Note in particular that if the negation of Int64 is not Int64 but
Int64 \ {kint64min} !!

Definition at line 177 of file Domain.java.

◆ size()

long com.google.ortools.util.Domain.size ( )

Returns the number of elements in the domain. It is capped at kint64max

Definition at line 137 of file Domain.java.

◆ swigRelease()

static long com.google.ortools.util.Domain.swigRelease ( Domain obj)
static

Definition at line 34 of file Domain.java.

◆ toString()

String com.google.ortools.util.Domain.toString ( )

Returns a compact string of a vector of intervals like "[1,4][6][10,20]".

Definition at line 205 of file Domain.java.

◆ unionWith()

Domain com.google.ortools.util.Domain.unionWith ( Domain domain)

Returns the union of D and domain.

Definition at line 191 of file Domain.java.

Member Data Documentation

◆ swigCMemOwn

transient boolean com.google.ortools.util.Domain.swigCMemOwn
protected

Definition at line 23 of file Domain.java.


The documentation for this class was generated from the following file: