ortools.util.python.sorted_interval_list

class Domain(pybind11_builtins.pybind11_object):

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.

Domain(arg0: int, arg1: int)

__init__(self: Domain, arg0: int, arg1: int) -> None

By default, Domain will be empty.

def all_values() -> Domain:

all_values() -> Domain

Returns the full domain Int64.

def from_values(values: List[int]) -> Domain:

from_values(values: List[int]) -> Domain

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

def from_intervals( intervals: List[List[int]]) -> Domain:

from_intervals(intervals: List[List[int]]) -> Domain

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

def from_flat_intervals( flat_intervals: List[int]) -> Domain:

from_flat_intervals(flat_intervals: List[int]) -> Domain

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

def addition_with( self, domain: Domain) -> Domain:

addition_with(self: Domain, domain: Domain) -> Domain

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

def complement(self) -> Domain:

complement(self: Domain) -> Domain

Returns the set Int64 ∖ D.

def contains(self, value: int) -> bool:

contains(self: Domain, value: int) -> bool

Returns true iff value is in Domain.

def flattened_intervals(self) -> List[int]:

flattened_intervals(self: Domain) -> List[int]

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, as a java or C# long[], as a python list of integers).

def intersection_with( self, domain: Domain) -> Domain:

intersection_with(self: Domain, domain: Domain) -> Domain

Returns the intersection of D and domain.

def is_empty(self) -> bool:

is_empty(self: Domain) -> bool

Returns true if this is the empty set.

def size(self) -> int:

size(self: Domain) -> int

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

def max(self) -> int:

max(self: Domain) -> int

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

def min(self) -> int:

min(self: Domain) -> int

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

def negation(self) -> Domain:

negation(self: Domain) -> Domain

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

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

def union_with( self, domain: Domain) -> Domain:

union_with(self: Domain, domain: Domain) -> Domain

Returns the union of D and domain.

def AllValues() -> Domain:

AllValues() -> Domain

Returns the full domain Int64.

def FromValues(values: List[int]) -> Domain:

FromValues(values: List[int]) -> Domain

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

def FromIntervals( intervals: List[List[int]]) -> Domain:

FromIntervals(intervals: List[List[int]]) -> Domain

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

def FromFlatIntervals( flat_intervals: List[int]) -> Domain:

FromFlatIntervals(flat_intervals: List[int]) -> Domain

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

def FlattenedIntervals(self) -> List[int]:

FlattenedIntervals(self: Domain) -> List[int]

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, as a java or C# long[], as a python list of integers).