template<typename DataType = EmptyIntervalData, typename NumericalType = DefaultIntervalNumericalType, typename IntervalKind = IntervalClosed>
struct genesis::utils::Interval< DataType, NumericalType, IntervalKind >
Type to store an interval (range) between two numbers, as used in the IntervalTree.
The implementation is based on interval-tree, which is published under the CC0-1.0 License (Creative Commons Zero v1.0 Universal); see our Acknowledgements for further details, and see IntervalTreeIterator, IntervalTreeNode, and IntervalTree for the other classes based on the original code. We changed the code to fit our standards, and in particular added support for per-interval data storage capability.
Definition at line 42 of file fwd.hpp.
|
| Interval (Interval &&)=default |
|
| Interval (Interval const &)=default |
|
| Interval (numerical_type low, numerical_type high) |
| Construct an interval. More...
|
|
| Interval (numerical_type low, numerical_type high, data_type &&data) |
| Construct an interval. More...
|
|
| Interval (numerical_type low, numerical_type high, data_type const &data) |
| Construct an interval. More...
|
|
| ~Interval ()=default |
|
data_type & | data () |
|
data_type const & | data () const |
|
numerical_type | high () const |
| Return the upper bound of the interval. More...
|
|
numerical_type | length () const |
| Return the length of the interval. More...
|
|
numerical_type | low () const |
| Return the lower bound of the interval. More...
|
|
| operator std::string () const |
|
numerical_type | operator- (Interval const &other) const |
| Calculates the distance between the two intervals. Overlapping intervals have 0 distance. More...
|
|
Interval & | operator= (Interval &&)=default |
|
Interval & | operator= (Interval const &)=default |
|
bool | overlaps (Interval const &other) const |
| Return whether the intervals overlap. More...
|
|
bool | overlaps (numerical_type l, numerical_type h) const |
| Return whether the intervals overlap. For when both intervals are closed. More...
|
|
bool | overlaps_exclusive (Interval const &other) const |
| Return whether the intervals overlap, excluding border. More...
|
|
bool | overlaps_exclusive (numerical_type l, numerical_type h) const |
| Return whether the intervals overlap, excluding border. For when at least one interval is open (l&r). More...
|
|
numerical_type | size () const |
| Return the size of the interval, that is, the distance between low and high. More...
|
|
std::string | to_string (bool narrow=false) const |
|
bool | within (Interval const &other) const |
| Return whether the given interval is in this. More...
|
|
bool | within (numerical_type value) const |
| Return whether the given value is in this. More...
|
|
Return the length of the interval.
For integer types, this is the number of values in the interval, which depends on whether the interval is open, closed, or half-open (as determined by the IntervalKind template parameter):
[1, 3]
has length 3
[1, 3)
and (1, 3]
have length 2
(1, 3)
has length 1
For other numerical types (in particular floating points), the length is simply the distance between the high() and low(), and hence the same as size().
Definition at line 500 of file interval.hpp.