Represents a continuous numeric interval with inclusive lower and upper bounds.
More...
#include <peak_common/types/peak_common_interval.hpp>
|
| constexpr | IntervalT (T minimum, T maximum) |
| | Constructs an interval with the given lower and upper bounds.
|
| constexpr T | GetMinimum () const |
| | Returns the lower boundary of the interval.
|
| constexpr T | GetMaximum () const |
| | Returns the upper boundary of the interval.
|
| constexpr T | Clamp (T value) const |
| | Clamps a value to the bounds of this interval.
|
| template<typename H> |
| constexpr bool | operator== (const IntervalT< H > &rhs) const |
| | Compares two intervals for equality (integral types).
|
| template<typename H> |
| constexpr bool | operator== (const IntervalT< H > &rhs) const |
| | Compares two intervals for approximate equality (floating-point types).
|
| constexpr bool | operator!= (const IntervalT &rhs) const |
| | Inequality comparison operator.
|
| std::string | ToString () const |
| | Returns a string representation of the interval.
|
|
| std::ostream & | operator<< (std::ostream &os, IntervalT interval) |
| | Outputs the interval as a human-readable string to a stream.
|
template<typename T>
class peak::common::detail::IntervalT< T >
Represents a continuous numeric interval with inclusive lower and upper bounds.
The interval is defined by two values: a minimum and a maximum. These values must satisfy the condition: minimum <= maximum.
- Template Parameters
-
| T | Must be an arithmetic type (integer or floating point). |
- Since
- ids_peak_common 1.0
◆ IntervalT()
Constructs an interval with the given lower and upper bounds.
- Parameters
-
| minimum | The lower boundary (inclusive). |
| maximum | The upper boundary (inclusive). |
- Exceptions
-
- Since
- ids_peak_common 1.0
◆ Clamp()
Clamps a value to the bounds of this interval.
Values below the minimum are adjusted to the minimum value, while values above the maximum are adjusted to the maximum value.
- Parameters
-
- Returns
- The clamped value within this interval's boundaries.
- Since
- ids_peak_common 2.1
◆ GetMaximum()
Returns the upper boundary of the interval.
- Returns
- The maximum value of the interval (inclusive).
- Since
- ids_peak_common 1.0
◆ GetMinimum()
Returns the lower boundary of the interval.
- Returns
- The minimum value of the interval (inclusive).
- Since
- ids_peak_common 1.0
◆ operator!=()
template<typename T>
| bool operator!= |
( |
const IntervalT< T > & | rhs | ) |
const |
|
inlineconstexpr |
Inequality comparison operator.
- Parameters
-
| rhs | The interval to compare with. |
- Returns
- True if the intervals differ in either minimum or maximum value.
- Since
- ids_peak_common 1.0
◆ operator==() [1/2]
template<typename T>
template<typename H>
| bool operator== |
( |
const IntervalT< H > & | rhs | ) |
const |
|
inlineconstexpr |
Compares two intervals for equality (integral types).
Checks whether the minimum and maximum values of both intervals are exactly the same.
- Parameters
-
| rhs | The interval to compare against. |
- Returns
- true if both intervals have the same minimum and maximum values; otherwise, false.
- Since
- ids_peak_common 1.0
◆ operator==() [2/2]
template<typename T>
template<typename H>
| bool operator== |
( |
const IntervalT< H > & | rhs | ) |
const |
|
inlineconstexpr |
Compares two intervals for approximate equality (floating-point types).
Determines whether two intervals are approximately equal by comparing their minimum and maximum values using a tolerance defined in ULPs (Units in the Last Place).
- Parameters
-
| rhs | The interval to compare against. |
- Returns
- true if both intervals have approximately equal minimum and maximum values; otherwise, false.
- Since
- ids_peak_common 1.0
◆ ToString()
template<typename T>
| std::string ToString |
( |
| ) |
const |
|
inline |
Returns a string representation of the interval.
- Returns
- A formatted string showing the minimum and maximum values.
- Since
- ids_peak_common 1.0
◆ operator<<
template<typename T>
| std::ostream & operator<< |
( |
std::ostream & | os, |
|
|
IntervalT< T > | interval ) |
|
friend |
Outputs the interval as a human-readable string to a stream.
- Parameters
-
| os | The output stream. |
| interval | The interval to print. |
- Returns
- Reference to the stream.
- Since
- ids_peak_common 1.0
The documentation for this class was generated from the following file: