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>
Public Member Functions | |
Interval ()=default | |
Constructor. | |
constexpr | Interval (T _leftValue, bool _leftClosed, T _rightValue, bool _rightClosed) |
Constructor. | |
bool | Contains (const Interval< T > &_other) const |
Check if the interval contains _other interval. | |
bool | Contains (const T &_value) const |
Check if the interval contains _value | |
bool | Empty () const |
Check if the interval is empty Some examples of empty intervals include (a, a), [a, a), and [a + 1, a]. | |
bool | Intersects (const Interval< T > &_other) const |
Check if the interval intersects _other interval. | |
bool | IsLeftClosed () const |
Check if the interval is left-closed. | |
bool | IsRightClosed () const |
Check if the interval is right-closed. | |
const T & | LeftValue () const |
Get the leftmost interval value. | |
bool | operator!= (const Interval< T > &_other) const |
Inequality test operator. | |
bool | operator== (const Interval< T > &_other) const |
Equality test operator. | |
const T & | RightValue () const |
Get the rightmost interval value. | |
Static Public Member Functions | |
static constexpr Interval< T > | Closed (T _leftValue, T _rightValue) |
Make a closed interval [_leftValue , _rightValue ]. | |
static constexpr Interval< T > | LeftClosed (T _leftValue, T _rightValue) |
Make a left-closed interval [_leftValue , _rightValue ) | |
static constexpr Interval< T > | Open (T _leftValue, T _rightValue) |
Make an open interval (_leftValue , _rightValue ) | |
static constexpr Interval< T > | RightClosed (T _leftValue, T _rightValue) |
Make a right-closed interval (_leftValue , _rightValue ]. | |
Static Public Attributes | |
static const Interval< T > & | Unbounded = detail::gUnboundedInterval<T> |
An unbounded interval (-∞, ∞) | |
Detailed Description
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
Constructor & Destructor Documentation
◆ Interval() [1/2]
◆ Interval() [2/2]
|
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
Member Function Documentation
◆ Closed()
|
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]
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]
Check if the interval contains _value
- Parameters
-
[in] _value value to check for membership
- Returns
- true if it is contained, false otherwise
Referenced by Interval< T >::operator!=(), and Interval< T >::operator==().
◆ Empty()
Check if the interval is empty Some examples of empty intervals include (a, a), [a, a), and [a + 1, a].
- Returns
- true if it is empty, false otherwise
Referenced by Interval< T >::Contains(), and Interval< T >::Intersects().
◆ Intersects()
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()
Check if the interval is left-closed.
- Returns
- true if the interval is left-closed, false otherwise
◆ IsRightClosed()
Check if the interval is right-closed.
- Returns
- true if the interval is right-closed, false otherwise
◆ LeftClosed()
|
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()
Get the leftmost interval value.
- Returns
- the leftmost interval value
◆ Open()
|
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!=()
Inequality test operator.
- Parameters
-
_other interval to check for inequality
- Returns
- true if intervals are unequal, false otherwise
References Interval< T >::Contains().
◆ operator==()
Equality test operator.
- Parameters
-
_other interval to check for equality
- Returns
- true if intervals are equal, false otherwise
References Interval< T >::Contains().
◆ RightClosed()
|
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()
Get the rightmost interval value.
- Returns
- the rightmost interval value
Member Data Documentation
◆ Unbounded
An unbounded interval (-∞, ∞)
The documentation for this class was generated from the following file: