Interval template type. More...
#include <Interval.hpp>
Public Types | |
using | value_type = T |
Value type. More... | |
using | limits = std::numeric_limits< value_type > |
Limits alias for the value_type . More... | |
Public Member Functions | |
PLAYRHO_CONSTEXPR | Interval ()=default |
Default constructor. More... | |
PLAYRHO_CONSTEXPR | Interval (const Interval &other)=default |
Copy constructor. More... | |
PLAYRHO_CONSTEXPR | Interval (Interval &&other)=default |
Move constructor. More... | |
PLAYRHO_CONSTEXPR | Interval (const value_type &v) noexcept |
Initializing constructor. More... | |
PLAYRHO_CONSTEXPR | Interval (const value_type &a, const value_type &b) noexcept |
Initializing constructor. More... | |
PLAYRHO_CONSTEXPR | Interval (const std::initializer_list< T > ilist) noexcept |
Initializing constructor. More... | |
~Interval () noexcept=default | |
Interval & | operator= (const Interval &other)=default |
Copy assignment operator. More... | |
Interval & | operator= (Interval &&other)=default |
Move assignment operator. More... | |
PLAYRHO_CONSTEXPR Interval & | Move (const value_type &v) noexcept |
Moves the interval by the given amount. More... | |
PLAYRHO_CONSTEXPR value_type | GetMin () const noexcept |
Gets the minimum value of this range. More... | |
PLAYRHO_CONSTEXPR value_type | GetMax () const noexcept |
Gets the maximum value of this range. More... | |
PLAYRHO_CONSTEXPR Interval & | Include (const value_type &v) noexcept |
Includes the given value into this interval. More... | |
PLAYRHO_CONSTEXPR Interval & | Include (const Interval &v) noexcept |
Includes the given interval into this interval. More... | |
PLAYRHO_CONSTEXPR Interval & | Intersect (const Interval &v) noexcept |
Intersects this interval with the given interval. More... | |
PLAYRHO_CONSTEXPR Interval & | Expand (const value_type &v) noexcept |
Expands this interval. More... | |
PLAYRHO_CONSTEXPR Interval & | ExpandEqually (const NonNegative< value_type > &v) noexcept |
Expands equally both ends of this interval. More... | |
Static Public Member Functions | |
static PLAYRHO_CONSTEXPR value_type | GetLowest () noexcept |
Gets the "lowest" value supported by the value_type . More... | |
static PLAYRHO_CONSTEXPR value_type | GetHighest () noexcept |
Gets the "highest" value supported by the value_type . More... | |
Related Functions | |
(Note that these are not member functions.) | |
using | LengthInterval = Interval< Length > |
Length Interval alias. More... | |
template<typename T > | |
PLAYRHO_CONSTEXPR T | GetCenter (const Interval< T > &v) noexcept |
Gets the center of the given interval. More... | |
template<typename T > | |
PLAYRHO_CONSTEXPR bool | IsIntersecting (const Interval< T > &a, const Interval< T > &b) noexcept |
Checks whether two value ranges have any intersection/overlap at all. More... | |
template<typename T > | |
PLAYRHO_CONSTEXPR Interval< T > | GetIntersection (Interval< T > a, const Interval< T > &b) noexcept |
Gets the intersecting interval of two given ranges. More... | |
template<typename T > | |
PLAYRHO_CONSTEXPR bool | operator== (const Interval< T > &a, const Interval< T > &b) noexcept |
Equality operator. More... | |
template<typename T > | |
PLAYRHO_CONSTEXPR bool | operator!= (const Interval< T > &a, const Interval< T > &b) noexcept |
Inequality operator. More... | |
template<typename T > | |
PLAYRHO_CONSTEXPR bool | operator< (const Interval< T > &lhs, const Interval< T > &rhs) noexcept |
Less-than operator. More... | |
template<typename T > | |
PLAYRHO_CONSTEXPR bool | operator<= (const Interval< T > &lhs, const Interval< T > &rhs) noexcept |
Less-than or equal-to operator. More... | |
template<typename T > | |
PLAYRHO_CONSTEXPR bool | operator> (const Interval< T > &lhs, const Interval< T > &rhs) noexcept |
Greater-than operator. More... | |
template<typename T > | |
PLAYRHO_CONSTEXPR bool | operator>= (const Interval< T > &lhs, const Interval< T > &rhs) noexcept |
Greater-than or equal-to operator. More... | |
Detailed Description
template<typename T>
class playrho::Interval< T >
Interval template type.
This type encapsulates an interval as a min-max value range relationship.
- Invariant
- The min and max values can only be the result of
std::minmax(a, b)
or the special values of the "highest" and "lowest" values supported by the type for this class respectively indicating the "unset" value.
Definition at line 39 of file Interval.hpp.
Member Typedef Documentation
◆ value_type
using playrho::Interval< T >::value_type = T |
Value type.
Alias for the type of the value that this class was template instantiated for.
Definition at line 46 of file Interval.hpp.
◆ limits
using playrho::Interval< T >::limits = std::numeric_limits<value_type> |
Limits alias for the value_type
.
Definition at line 49 of file Interval.hpp.
Constructor & Destructor Documentation
◆ Interval() [1/6]
|
inlinedefault |
Default constructor.
Constructs an "unset" interval.
- Postcondition
GetMin()
returns the value ofGetHighest()
.-
GetMax()
returns the value ofGetLowest()
.
◆ Interval() [2/6]
|
inlinedefault |
◆ Interval() [3/6]
|
inlinedefault |
◆ Interval() [4/6]
|
inlineexplicitnoexcept |
Initializing constructor.
Definition at line 86 of file Interval.hpp.
◆ Interval() [5/6]
|
inlinenoexcept |
Initializing constructor.
Definition at line 93 of file Interval.hpp.
◆ Interval() [6/6]
|
inlinenoexcept |
Initializing constructor.
Definition at line 100 of file Interval.hpp.
◆ ~Interval()
|
defaultnoexcept |
Member Function Documentation
◆ GetLowest()
|
inlinestaticnoexcept |
Gets the "lowest" value supported by the value_type
.
- Returns
- Negative infinity if supported by the value type, limits::lowest() otherwise.
Definition at line 54 of file Interval.hpp.
◆ GetHighest()
|
inlinestaticnoexcept |
Gets the "highest" value supported by the value_type
.
- Returns
- Positive infinity if supported by the value type, limits::max() otherwise.
Definition at line 62 of file Interval.hpp.
◆ operator=() [1/2]
|
default |
◆ operator=() [2/2]
|
default |
◆ Move()
|
inlinenoexcept |
Moves the interval by the given amount.
- Warning
- Behavior is undefined if incrementing the min or max value by the given amount overflows the finite range of the
value_type
,
Definition at line 121 of file Interval.hpp.
◆ GetMin()
|
inlinenoexcept |
Gets the minimum value of this range.
Definition at line 129 of file Interval.hpp.
◆ GetMax()
|
inlinenoexcept |
Gets the maximum value of this range.
Definition at line 135 of file Interval.hpp.
◆ Include() [1/2]
|
inlinenoexcept |
Includes the given value into this interval.
- Note
- If this value is the "unset" value then the result of this operation will be the given value.
- Parameters
-
v Value to "include" into this value.
- Postcondition
- This value's "min" is the minimum of the given value and this value's "min".
Definition at line 145 of file Interval.hpp.
◆ Include() [2/2]
|
inlinenoexcept |
Includes the given interval into this interval.
- Note
- If this value is the "unset" value then the result of this operation will be the given value.
- Parameters
-
v Value to "include" into this value.
- Postcondition
- This value's "min" is the minimum of the given value's "min" and this value's "min".
Definition at line 158 of file Interval.hpp.
◆ Intersect()
|
inlinenoexcept |
Intersects this interval with the given interval.
Definition at line 166 of file Interval.hpp.
◆ Expand()
|
inlinenoexcept |
Expands this interval.
Expands this interval by decreasing the min value if the given value is negative, or by increasing the max value if the given value is positive.
- Parameters
-
v Amount to expand this interval by.
- Warning
- Behavior is undefined if expanding the range by the given amount overflows the range of the
value_type
,
Definition at line 181 of file Interval.hpp.
◆ ExpandEqually()
|
inlinenoexcept |
Expands equally both ends of this interval.
Expands equally this interval by decreasing the min value and by increasing the max value by the given amount.
- Note
- This operation has no effect if this interval is "unset".
- Parameters
-
v Amount to expand both ends of this interval by.
- Warning
- Behavior is undefined if expanding the range by the given amount overflows the range of the
value_type
,
Definition at line 201 of file Interval.hpp.
Friends And Related Function Documentation
◆ LengthInterval
|
related |
Length Interval alias.
Definition at line 32 of file Intervals.hpp.
◆ GetCenter()
|
related |
Gets the center of the given interval.
- Warning
- Behavior is undefined if the difference between the given range's max and min values overflows the range of the
Interval::value_type
.
Definition at line 242 of file Interval.hpp.
◆ IsIntersecting()
|
related |
Checks whether two value ranges have any intersection/overlap at all.
Definition at line 251 of file Interval.hpp.
◆ GetIntersection()
|
related |
Gets the intersecting interval of two given ranges.
Definition at line 261 of file Interval.hpp.
◆ operator==()
|
related |
Equality operator.
- Note
- Satisfies the
EqualityComparable
concept for Interval objects.
Definition at line 292 of file Interval.hpp.
◆ operator!=()
|
related |
Inequality operator.
- Note
- Satisfies the
EqualityComparable
concept for Interval objects.
Definition at line 302 of file Interval.hpp.
◆ operator<()
|
related |
Less-than operator.
- Note
- Provides a "strict weak ordering" relation.
- This is a lexicographical comparison.
-
Obeys the
LessThanComparable
concept:for all a, !(a < a); if (a < b) then !(b < a); if (a < b) and (b < c) then (a < c); with equiv = !(a < b) && !(b < a), if equiv(a, b) and equiv(b, c), then equiv(a, c).
- See also
- https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings
- http://en.cppreference.com/w/cpp/concept/LessThanComparable
Definition at line 318 of file Interval.hpp.
◆ operator<=()
|
related |
Less-than or equal-to operator.
- Note
- Provides a "strict weak ordering" relation.
- This is a lexicographical comparison.
Definition at line 330 of file Interval.hpp.
◆ operator>()
|
related |
Greater-than operator.
- Note
- Provides a "strict weak ordering" relation.
- This is a lexicographical comparison.
Definition at line 342 of file Interval.hpp.
◆ operator>=()
|
related |
Greater-than or equal-to operator.
- Note
- Provides a "strict weak ordering" relation.
- This is a lexicographical comparison.
Definition at line 354 of file Interval.hpp.
The documentation for this class was generated from the following files:
- Common/Interval.hpp
- Common/Intervals.hpp