|
Clingo
|
A set of intervals. More...
#include <interval_set.hh>
Classes | |
| struct | interval |
| An interval determined by a left and a right bound. More... | |
| struct | left_bound |
| A left bound of an interval. More... | |
| struct | right_bound |
| A right bound of an interval. More... | |
Public Types | |
| using | value_type = T |
| The value type used as bounds. | |
| using | interval_vector = small_vector< interval > |
| The vector used to store intervals. | |
| using | iterator = typename interval_vector::const_iterator |
| An iterator over the intervals in the set. | |
Public Member Functions | |
| interval_set ()=default | |
| Construct an empty interval set. | |
| ~interval_set ()=default | |
| Destroy the interval set. | |
| interval_set (interval_set const &other)=default | |
| The default copy constructor. | |
| auto | operator= (interval_set const &other) -> interval_set &=default |
| The default copy assignment. | |
| interval_set (interval_set &&other) noexcept=default | |
| The default move constructor. | |
| auto | operator= (interval_set &&other) noexcept -> interval_set &=default |
| The default copy assignment. | |
| interval_set (std::initializer_list< interval > list) | |
| Construct an interval set containing the given intervals. | |
| void | reserve (size_t n) |
| Reserve space for at least n elements. | |
| auto | release () -> interval_vector |
| Releases the underlying vector. | |
| auto | add (interval const &x) -> interval_set & |
| Add the given interval to the set. | |
| auto | remove (interval const &x) -> interval_set & |
| Subtract the given interval from the set. | |
| auto | contains (interval const &x) const -> bool |
| Check if the set contains the given interval. | |
| auto | contains (T const &x) const -> bool |
| Check if the set contains the given value. | |
| auto | intersects (interval const &x) const -> bool |
| Check if the set intersects the given interval. | |
| auto | empty () const -> bool |
| Check if the set is empty. | |
| auto | size () const -> size_t |
| Get the size of the set. | |
| auto | front () const -> interval const & |
| Get the first interval in the set. | |
| auto | back () const -> interval const & |
| Get the last interval in the set. | |
| auto | begin () const -> iterator |
| Get an iterator to the beginning of the set. | |
| auto | end () const -> iterator |
| Get an iterator to the end of the set. | |
| void | clear () |
| Clear the set. | |
| auto | intersect (interval_set const &set) const -> interval_set |
| Compute the intersection of two interval sets. | |
| auto | difference (interval_set const &set) const -> interval_set |
| Compute the difference between two interval sets. | |
Friends | |
| auto | operator< (left_bound const &x, left_bound const &y) -> bool |
| Left bound x is smaller than left bound y. | |
| auto | operator<= (left_bound const &x, left_bound const &y) -> bool |
| Left bound x is smaller than or equal to left bound y. | |
| auto | operator< (left_bound const &x, right_bound const &y) -> bool |
| There is a gap between x and y. | |
| auto | operator< (right_bound const &x, right_bound const &y) -> bool |
| Right bound x is smaller than right bound y. | |
| auto | operator<= (right_bound const &x, right_bound const &y) -> bool |
| Right bound x is smaller than or equal to right bound y. | |
| auto | operator< (right_bound const &x, left_bound const &y) -> bool |
| There is a gap between x and y. | |
| auto | operator< (interval const &x, interval const &y) -> bool |
| Interval x is before interval y. | |
| auto | operator< (value_type const &x, interval const &y) -> bool |
| Value x is before interval y. | |
| auto | operator< (interval const &x, value_type const &y) -> bool |
| Interval x is before value y. | |
A set of intervals.
Closed and open intervals of bounds are supported.
Note that intervals involving discrete values should be closed in a post-processing step to obtain a canonical set representation, e.g., the inteval (1,2) should be removed and (1,3) be represented as [2].
|
inline |
Add the given interval to the set.
| x | the interval to add |
|
inline |
Check if the set contains the given interval.
| x | the interval to check |
|
inline |
Check if the set contains the given value.
| x | the value to check |
|
inline |
Check if the set intersects the given interval.
| x | the interval to check |
|
inline |
Subtract the given interval from the set.
| x | the interval to subtract |
|
inline |
Reserve space for at least n elements.
Calls the reserve method of the underlying vector.
| n | the number of elements to reserve space for |
|
friend |
There is a gap between x and y.
For example, two intervals with bounds x and y overlap.
Can be used to check whether an interval is empty.
|
friend |
There is a gap between x and y.
For example, two intervals with bounds x and y do not overlap:
Can be used to check whether two intervals can be merged.