procset¶
This package implements for Python a memory-efficient representation of closed-interval sets.
- The package provides two modules:
procsetandintsetwrap: procsetis an implementation aiming at providing a pythonic experience: it should be the preferred module for any new project.intsetwrapis a wrapper aroundprocsetproviding the old API ofinterval_set: do not use in any new project.
A ProcSet is an hybrid between a set and a list of
indexes.
More precisely, a ProcSet object is an ordered collection of
unique non-negative int.
It supports most of set operations: notably membership testing,
mathematical operations such as intersection, union, and (symmetric)
difference; with the additional ability to access its elements by position.
The ProcSet type is mutable, as its content can be modified using
methods such as insert().
Since it is mutable, it has no hash value and cannot be used as either a
dictionary key or as an element of another set.
String representation of interval sets¶
In the scheduling community, interval sets often are encoded as strings where
the string 'a-b' (middle symbol is a dash, ascii 0x2d) represents the
integer interval \([a, b]\), with the convention that the string a
represents the degenerate case of the singleton \(\{a\}\).
An interval set with many disjoint intervals is encoded by joining interval
representations with a space (ascii 0x20): for example a-b c d-e
represents \([a, b] \cup \{c\} \cup [d, e]\).
Warning
There are many different strings representing the same interval set. For the description of a canonical representation, please refer to the documentation of Batsim.