ortools.util.python.sorted_interval_list
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.
__init__(self: ortools.util.python.sorted_interval_list.Domain, arg0: int, arg1: int) -> None
By default, Domain will be empty.
all_values() -> ortools.util.python.sorted_interval_list.Domain
Returns the full domain Int64.
from_values(values: list[int]) -> ortools.util.python.sorted_interval_list.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
from_intervals(intervals: list[list[int]]) -> ortools.util.python.sorted_interval_list.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).
from_flat_intervals(flat_intervals: list[int]) -> ortools.util.python.sorted_interval_list.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).
addition_with(self: ortools.util.python.sorted_interval_list.Domain, domain: ortools.util.python.sorted_interval_list.Domain) -> ortools.util.python.sorted_interval_list.Domain
Returns {x ∈ Int64, ∃ a ∈ D, ∃ b ∈ domain, x = a + b}.
complement(self: ortools.util.python.sorted_interval_list.Domain) -> ortools.util.python.sorted_interval_list.Domain
Returns the set Int64 ∖ D.
contains(self: ortools.util.python.sorted_interval_list.Domain, value: int) -> bool
Returns true iff value is in Domain.
flattened_intervals(self: ortools.util.python.sorted_interval_list.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
intersection_with(self: ortools.util.python.sorted_interval_list.Domain, domain: ortools.util.python.sorted_interval_list.Domain) -> ortools.util.python.sorted_interval_list.Domain
Returns the intersection of D and domain.
is_empty(self: ortools.util.python.sorted_interval_list.Domain) -> bool
Returns true if this is the empty set.
size(self: ortools.util.python.sorted_interval_list.Domain) -> int
Returns the number of elements in the domain. It is capped at kint64max
max(self: ortools.util.python.sorted_interval_list.Domain) -> int
Returns the max value of the domain. The domain must not be empty.
min(self: ortools.util.python.sorted_interval_list.Domain) -> int
Returns the min value of the domain. The domain must not be empty.
negation(self: ortools.util.python.sorted_interval_list.Domain) -> ortools.util.python.sorted_interval_list.Domain
Returns {x ∈ Int64, ∃ e ∈ D, x = -e}.
Note in particular that if the negation of Int64 is not Int64 but Int64 \ {kint64min} !!
union_with(self: ortools.util.python.sorted_interval_list.Domain, domain: ortools.util.python.sorted_interval_list.Domain) -> ortools.util.python.sorted_interval_list.Domain
Returns the union of D and domain.
AllValues() -> ortools.util.python.sorted_interval_list.Domain
Returns the full domain Int64.
FromValues(values: list[int]) -> ortools.util.python.sorted_interval_list.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
FromIntervals(intervals: list[list[int]]) -> ortools.util.python.sorted_interval_list.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).
FromFlatIntervals(flat_intervals: list[int]) -> ortools.util.python.sorted_interval_list.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).
FlattenedIntervals(self: ortools.util.python.sorted_interval_list.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