The Interval class represents a range of real numbers. Intervals may be open (a, b), left-closed [a, b), right-closed (a, b], or fully closed [a, b].
More...
#include <gz/math/Interval.hh>
|
static constexpr Interval< T > | Closed (T _leftValue, T _rightValue) |
| Make a closed interval [_leftValue , _rightValue ]. More...
|
|
static constexpr Interval< T > | LeftClosed (T _leftValue, T _rightValue) |
| Make a left-closed interval [_leftValue , _rightValue ) More...
|
|
static constexpr Interval< T > | Open (T _leftValue, T _rightValue) |
| Make an open interval (_leftValue , _rightValue ) More...
|
|
static constexpr Interval< T > | RightClosed (T _leftValue, T _rightValue) |
| Make a right-closed interval (_leftValue , _rightValue ]. More...
|
|
template<typename T>
class gz::math::Interval< T >
The Interval class represents a range of real numbers. Intervals may be open (a, b), left-closed [a, b), right-closed (a, b], or fully closed [a, b].
Example
#include <iostream>
int main(int argc, char **argv)
{
std::cout <<
"The " << defaultInterval <<
" interval is empty: "
std::cout <<
"The " << openInterval <<
" interval contains its endpoints: "
std::cout <<
"The " << closedInterval <<
" interval contains its endpoints: "
<< (closedInterval.Contains(closedInterval.LeftValue()) ||
closedInterval.Contains(closedInterval.RightValue()))
std::cout <<
"Intervals " << closedInterval <<
" and " << openInterval
<<
" intersect: " << closedInterval.
Intersects(openInterval)
<< " interval contains all previous non-empty intervals: "
}
◆ Interval() [1/2]
◆ Interval() [2/2]
constexpr Interval |
( |
T |
_leftValue, |
|
|
bool |
_leftClosed, |
|
|
T |
_rightValue, |
|
|
bool |
_rightClosed |
|
) |
| |
|
inlineconstexpr |
Constructor.
- Parameters
-
[in] | _leftValue | leftmost interval value |
[in] | _leftClosed | whether the interval is left-closed or not |
[in] | _rightValue | rightmost interval value |
[in] | _rightClosed | whether the interval is right-closed or not |
◆ Closed()
static constexpr Interval<T> Closed |
( |
T |
_leftValue, |
|
|
T |
_rightValue |
|
) |
| |
|
inlinestaticconstexpr |
Make a closed interval [_leftValue
, _rightValue
].
- Parameters
-
[in] | _leftValue | leftmost interval value |
[in] | _rightValue | rightmost interval value |
- Returns
- the closed interval
References std::move().
◆ Contains() [1/2]
bool Contains |
( |
const Interval< T > & |
_other | ) |
const |
|
inline |
Check if the interval contains _other
interval.
- Parameters
-
[in] | _other | interval to check for membership |
- Returns
- true if it is contained, false otherwise
References Interval< T >::Empty().
◆ Contains() [2/2]
bool Contains |
( |
const T & |
_value | ) |
const |
|
inline |
◆ Empty()
◆ Intersects()
bool Intersects |
( |
const Interval< T > & |
_other | ) |
const |
|
inline |
Check if the interval intersects _other
interval.
- Parameters
-
[in] | _other | interval to check for intersection |
- Returns
- true if both intervals intersect, false otherwise
References Interval< T >::Empty().
◆ IsLeftClosed()
bool IsLeftClosed |
( |
| ) |
const |
|
inline |
Check if the interval is left-closed.
- Returns
- true if the interval is left-closed, false otherwise
◆ IsRightClosed()
bool IsRightClosed |
( |
| ) |
const |
|
inline |
Check if the interval is right-closed.
- Returns
- true if the interval is right-closed, false otherwise
◆ LeftClosed()
static constexpr Interval<T> LeftClosed |
( |
T |
_leftValue, |
|
|
T |
_rightValue |
|
) |
| |
|
inlinestaticconstexpr |
Make a left-closed interval [_leftValue
, _rightValue
)
- Parameters
-
[in] | _leftValue | leftmost interval value |
[in] | _rightValue | rightmost interval value |
- Returns
- the left-closed interval
References std::move().
◆ LeftValue()
const T& LeftValue |
( |
| ) |
const |
|
inline |
◆ Open()
static constexpr Interval<T> Open |
( |
T |
_leftValue, |
|
|
T |
_rightValue |
|
) |
| |
|
inlinestaticconstexpr |
Make an open interval (_leftValue
, _rightValue
)
- Parameters
-
[in] | _leftValue | leftmost interval value |
[in] | _rightValue | rightmost interval value |
- Returns
- the open interval
References std::move().
◆ operator!=()
bool operator!= |
( |
const Interval< T > & |
_other | ) |
const |
|
inline |
Inequality test operator.
- Parameters
-
_other | interval to check for inequality |
- Returns
- true if intervals are unequal, false otherwise
References Interval< T >::Contains().
◆ operator==()
bool operator== |
( |
const Interval< T > & |
_other | ) |
const |
|
inline |
Equality test operator.
- Parameters
-
_other | interval to check for equality |
- Returns
- true if intervals are equal, false otherwise
References Interval< T >::Contains().
◆ RightClosed()
static constexpr Interval<T> RightClosed |
( |
T |
_leftValue, |
|
|
T |
_rightValue |
|
) |
| |
|
inlinestaticconstexpr |
Make a right-closed interval (_leftValue
, _rightValue
].
- Parameters
-
[in] | _leftValue | leftmost interval value |
[in] | _rightValue | rightmost interval value |
- Returns
- the left-closed interval
References std::move().
◆ RightValue()
const T& RightValue |
( |
| ) |
const |
|
inline |
◆ Unbounded
const Interval< T > & Unbounded = detail::gUnboundedInterval<T> |
|
static |
An unbounded interval (-∞, ∞)
The documentation for this class was generated from the following file: