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
 
Intervaloperator= (const Interval &other)=default
 Copy assignment operator. More...
 
Intervaloperator= (Interval &&other)=default
 Move assignment operator. More...
 
PLAYRHO_CONSTEXPR IntervalMove (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 IntervalInclude (const value_type &v) noexcept
 Includes the given value into this interval. More...
 
PLAYRHO_CONSTEXPR IntervalInclude (const Interval &v) noexcept
 Includes the given interval into this interval. More...
 
PLAYRHO_CONSTEXPR IntervalIntersect (const Interval &v) noexcept
 Intersects this interval with the given interval. More...
 
PLAYRHO_CONSTEXPR IntervalExpand (const value_type &v) noexcept
 Expands this interval. More...
 
PLAYRHO_CONSTEXPR IntervalExpandEqually (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_CONSTEXPRGetCenter (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.
See also
https://en.wikipedia.org/wiki/Interval_(mathematics)

Definition at line 39 of file Interval.hpp.

Member Typedef Documentation

◆ value_type

template<typename T >
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

template<typename T >
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]

template<typename T >
PLAYRHO_CONSTEXPR playrho::Interval< T >::Interval ( )
inlinedefault

Default constructor.

Constructs an "unset" interval.

Postcondition
GetMin() returns the value of GetHighest().
GetMax() returns the value of GetLowest().

◆ Interval() [2/6]

template<typename T >
PLAYRHO_CONSTEXPR playrho::Interval< T >::Interval ( const Interval< T > &  other)
inlinedefault

Copy constructor.

Postcondition
GetMin() returns the value of other.GetMin().
GetMax() returns the value of other.GetMax().

◆ Interval() [3/6]

template<typename T >
PLAYRHO_CONSTEXPR playrho::Interval< T >::Interval ( Interval< T > &&  other)
inlinedefault

Move constructor.

Postcondition
GetMin() returns the value of other.GetMin().
GetMax() returns the value of other.GetMax().

◆ Interval() [4/6]

template<typename T >
PLAYRHO_CONSTEXPR playrho::Interval< T >::Interval ( const value_type v)
inlineexplicitnoexcept

Initializing constructor.

Postcondition
GetMin() returns the value of v.
GetMax() returns the value of v.

Definition at line 86 of file Interval.hpp.

◆ Interval() [5/6]

template<typename T >
PLAYRHO_CONSTEXPR playrho::Interval< T >::Interval ( const value_type a,
const value_type b 
)
inlinenoexcept

Initializing constructor.

Definition at line 93 of file Interval.hpp.

◆ Interval() [6/6]

template<typename T >
PLAYRHO_CONSTEXPR playrho::Interval< T >::Interval ( const std::initializer_list< T >  ilist)
inlinenoexcept

Initializing constructor.

Definition at line 100 of file Interval.hpp.

◆ ~Interval()

template<typename T >
playrho::Interval< T >::~Interval ( )
defaultnoexcept

Member Function Documentation

◆ GetLowest()

template<typename T >
static PLAYRHO_CONSTEXPR value_type playrho::Interval< T >::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()

template<typename T >
static PLAYRHO_CONSTEXPR value_type playrho::Interval< T >::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]

template<typename T >
Interval& playrho::Interval< T >::operator= ( const Interval< T > &  other)
default

Copy assignment operator.

Postcondition
GetMin() returns the value of other.GetMin().
GetMax() returns the value of other.GetMax().

◆ operator=() [2/2]

template<typename T >
Interval& playrho::Interval< T >::operator= ( Interval< T > &&  other)
default

Move assignment operator.

Postcondition
GetMin() returns the value of other.GetMin().
GetMax() returns the value of other.GetMax().

◆ Move()

template<typename T >
PLAYRHO_CONSTEXPR Interval& playrho::Interval< T >::Move ( const value_type v)
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()

template<typename T >
PLAYRHO_CONSTEXPR value_type playrho::Interval< T >::GetMin ( ) const
inlinenoexcept

Gets the minimum value of this range.

Definition at line 129 of file Interval.hpp.

◆ GetMax()

template<typename T >
PLAYRHO_CONSTEXPR value_type playrho::Interval< T >::GetMax ( ) const
inlinenoexcept

Gets the maximum value of this range.

Definition at line 135 of file Interval.hpp.

◆ Include() [1/2]

template<typename T >
PLAYRHO_CONSTEXPR Interval& playrho::Interval< T >::Include ( const value_type v)
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
vValue 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]

template<typename T >
PLAYRHO_CONSTEXPR Interval& playrho::Interval< T >::Include ( const Interval< T > &  v)
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
vValue 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()

template<typename T >
PLAYRHO_CONSTEXPR Interval& playrho::Interval< T >::Intersect ( const Interval< T > &  v)
inlinenoexcept

Intersects this interval with the given interval.

Definition at line 166 of file Interval.hpp.

◆ Expand()

template<typename T >
PLAYRHO_CONSTEXPR Interval& playrho::Interval< T >::Expand ( const value_type v)
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
vAmount 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()

template<typename T >
PLAYRHO_CONSTEXPR Interval& playrho::Interval< T >::ExpandEqually ( const NonNegative< value_type > &  v)
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
vAmount 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

template<typename T >
using LengthInterval = Interval<Length>
related

Length Interval alias.

Definition at line 32 of file Intervals.hpp.

◆ GetCenter()

template<typename T >
PLAYRHO_CONSTEXPR T GetCenter ( const Interval< T > &  v)
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()

template<typename T >
PLAYRHO_CONSTEXPR bool IsIntersecting ( const Interval< T > &  a,
const Interval< T > &  b 
)
related

Checks whether two value ranges have any intersection/overlap at all.

Definition at line 251 of file Interval.hpp.

◆ GetIntersection()

template<typename T >
PLAYRHO_CONSTEXPR Interval< T > GetIntersection ( Interval< T >  a,
const Interval< T > &  b 
)
related

Gets the intersecting interval of two given ranges.

Definition at line 261 of file Interval.hpp.

◆ operator==()

template<typename T >
PLAYRHO_CONSTEXPR bool operator== ( const Interval< T > &  a,
const Interval< T > &  b 
)
related

Equality operator.

Note
Satisfies the EqualityComparable concept for Interval objects.
See also
http://en.cppreference.com/w/cpp/concept/EqualityComparable

Definition at line 292 of file Interval.hpp.

◆ operator!=()

template<typename T >
PLAYRHO_CONSTEXPR bool operator!= ( const Interval< T > &  a,
const Interval< T > &  b 
)
related

Inequality operator.

Note
Satisfies the EqualityComparable concept for Interval objects.
See also
http://en.cppreference.com/w/cpp/concept/EqualityComparable

Definition at line 302 of file Interval.hpp.

◆ operator<()

template<typename T >
PLAYRHO_CONSTEXPR bool operator< ( const Interval< T > &  lhs,
const Interval< T > &  rhs 
)
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<=()

template<typename T >
PLAYRHO_CONSTEXPR bool operator<= ( const Interval< T > &  lhs,
const Interval< T > &  rhs 
)
related

Less-than or equal-to operator.

Note
Provides a "strict weak ordering" relation.
This is a lexicographical comparison.
See also
https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings

Definition at line 330 of file Interval.hpp.

◆ operator>()

template<typename T >
PLAYRHO_CONSTEXPR bool operator> ( const Interval< T > &  lhs,
const Interval< T > &  rhs 
)
related

Greater-than operator.

Note
Provides a "strict weak ordering" relation.
This is a lexicographical comparison.
See also
https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings

Definition at line 342 of file Interval.hpp.

◆ operator>=()

template<typename T >
PLAYRHO_CONSTEXPR bool operator>= ( const Interval< T > &  lhs,
const Interval< T > &  rhs 
)
related

Greater-than or equal-to operator.

Note
Provides a "strict weak ordering" relation.
This is a lexicographical comparison.
See also
https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings

Definition at line 354 of file Interval.hpp.


The documentation for this class was generated from the following files: