|
| constexpr | Interval () |
| | Construct a new Interval object.
|
| |
| constexpr | Interval (T lower, T upper) noexcept |
| | Construct a new Interval object.
|
| |
| constexpr | Interval (const T &value) |
| | Construct a new Interval object.
|
| |
| constexpr auto | operator= (const T &value) -> Interval & |
| | Assignment operator.
|
| |
| constexpr auto | lb () const -> const T & |
| | lower bound
|
| |
| constexpr auto | ub () const -> const T & |
| | upper bound
|
| |
| constexpr auto | measure () const -> T |
| | measure (length)
|
| |
| constexpr auto | is_invalid () const -> bool |
| | Checks if the interval is invalid.
|
| |
| template<typename U > |
| constexpr auto | overlaps (const U &other_interval) const -> bool |
| | Checks if the current interval overlaps with another interval.
|
| |
| template<typename U > |
| constexpr auto | contains (const U &other_interval) const -> bool |
| | Checks if the current interval contains another interval.
|
| |
| template<typename U > |
| constexpr auto | intersect_with (const U &other_interval) const |
| | Computes the intersection of the current interval with another interval or scalar value.
|
| |
| template<typename U > |
| constexpr auto | hull_with (const U &other_interval) const |
| | Computes the hull of the current interval with another interval or scalar value.
|
| |
| template<typename U > |
| constexpr auto | min_dist_with (const U &other_interval) const -> T |
| | Computes the minimum distance between the current interval and the other_interval interval or scalar value.
|
| |
| constexpr auto | nearest_to (const T &reference_value) const -> T |
| | Find the nearest point to a given value.
|
| |
| template<typename U > |
| constexpr auto | min_dist_change_with (U &other_interval) -> T |
| | Computes the minimum distance between the current interval and the other_interval interval or scalar value, and updates the interval bounds accordingly.
|
| |
| constexpr auto | get_center () const -> T |
| | Calculate the center of the interval.
|
| |
| constexpr auto | lower_corner () const -> T |
| | Get the lower corner of the interval.
|
| |
| constexpr auto | upper_corner () const -> T |
| | Get the upper corner of the interval.
|
| |
|
definie ==, !=, <, >, <=, >=.
|
| template<typename U > |
| constexpr auto | operator== (const Interval< U > &rhs) const -> bool |
| | Equality comparison operator for Interval objects.
|
| |
| template<typename U > |
| constexpr auto | operator!= (const Interval< U > &rhs) const -> bool |
| | Not equal to comparison operator for Interval objects.
|
| |
| template<typename U > |
| constexpr auto | operator<=> (const U &rhs) const -> std::weak_ordering |
| | Spaceship comparison operator for Interval objects.
|
| |
| constexpr auto | operator<=> (const T &lhs, const Interval &rhs) -> std::weak_ordering |
| | Spaceship comparison operator for comparing a value with an Interval object.
|
| |
|
definie +, -, *, /, +=, -=, +=, /=, etc.
|
| constexpr auto | operator- () const -> Interval |
| | Negation operator for an Interval object.
|
| |
| template<typename U > |
| constexpr auto | operator+= (const U &value) -> Interval & |
| | Add a value to the lower and upper bounds of the interval.
|
| |
| template<typename U > |
| constexpr auto | operator-= (const U &value) -> Interval & |
| | Subtract a scalar value from an Interval object.
|
| |
| constexpr auto | enlarge_with (const T &value) const |
| | Enlarge the interval by subtracting value from the lower bound and adding value to the upper bound.
|
| |
| template<typename U > |
| constexpr auto | operator+ (Interval rhs, const U &value) -> Interval |
| | Add a scalar value to an Interval object.
|
| |
| constexpr auto | operator+ (const T &value, Interval rhs) -> Interval |
| | Add (by a scalar)
|
| |
| template<typename U > |
| constexpr auto | operator- (const Interval &rhs, const U &value) -> Interval |
| | Subtract a scalar value from an Interval object.
|
| |
template<typename T = int>
class recti::Interval< T >
Interval.
The above code is defining a template class called "Interval" with a default template parameter of type "int". The class has two private member variables: "_lb" (lower bound) and "_ub" (upper bound).
- Template Parameters
-
template<typename T = int>
template<typename U >
| constexpr auto recti::Interval< T >::contains |
( |
const U & |
other_interval | ) |
const -> bool |
|
inlineconstexpr |
Checks if the current interval contains another interval.
This function checks if the current Interval object contains the interval represented by the other_interval parameter. If the other_interval parameter has a lb() and ub() member function, it checks if the lower bound of the current interval is less than or equal to the lower bound of the other_interval interval, and the upper bound of the current interval is greater than or equal to the upper bound of the other_interval interval. Otherwise, it assumes the other_interval parameter is a scalar value and checks if it is within the bounds of the current interval.
- Template Parameters
-
| U | The type of the other_interval interval or scalar value. |
- Parameters
-
| [in] | other_interval | The interval or scalar value to check if it is contained within the current interval. |
- Returns
true if the current interval contains the other_interval interval or scalar value, false otherwise.
template<typename T = int>
template<typename U >
| constexpr auto recti::Interval< T >::hull_with |
( |
const U & |
other_interval | ) |
const |
|
inlineconstexpr |
Computes the hull of the current interval with another interval or scalar value.
This function returns a new Interval object that represents the hull of the current Interval object with the interval or scalar value represented by the other_interval parameter. If the other_interval parameter has lb() and ub() member functions, it computes the hull using the lower and upper bounds of both intervals. Otherwise, it assumes the other_interval parameter is a scalar value and computes the hull using the lower and upper bounds of the current interval and the scalar value.
- Template Parameters
-
| U | The type of the other_interval interval or scalar value. |
- Parameters
-
| [in] | other_interval | The interval or scalar value to intersect with the current interval. |
- Returns
- The hull of the current interval with the
other_interval interval or scalar value.
template<typename T = int>
template<typename U >
| constexpr auto recti::Interval< T >::intersect_with |
( |
const U & |
other_interval | ) |
const |
|
inlineconstexpr |
Computes the intersection of the current interval with another interval or scalar value.
This function returns a new Interval object that represents the intersection of the current Interval object with the interval or scalar value represented by the other_interval parameter. If the other_interval parameter has lb() and ub() member functions, it computes the intersection using the lower and upper bounds of both intervals. Otherwise, it assumes the other_interval parameter is a scalar value and computes the intersection using the lower and upper bounds of the current interval and the scalar value.
- Template Parameters
-
| U | The type of the other_interval interval or scalar value. |
- Parameters
-
| [in] | other_interval | The interval or scalar value to intersect with the current interval. |
- Returns
- The intersection of the current interval with the
other_interval interval or scalar value.
template<typename T = int>
template<typename U >
| constexpr auto recti::Interval< T >::min_dist_change_with |
( |
U & |
other_interval | ) |
-> T |
|
inlineconstexpr |
Computes the minimum distance between the current interval and the other_interval interval or scalar value, and updates the interval bounds accordingly.
This function returns the minimum distance between the current interval and the interval or scalar value represented by the other_interval parameter. If the other_interval parameter is less than the current interval, the function updates the lower bound of the current interval to the upper bound, and returns the distance between the new lower bound and the other_interval parameter. If the other_interval parameter is greater than the current interval, the function updates the upper bound of the current interval to the lower bound, and returns the distance between the new upper bound and the other_interval parameter. If the other_interval parameter is within the current interval, the function updates the interval to the intersection of the current interval and the other_interval interval or scalar value, and returns 0.
- Template Parameters
-
| U | The type of the other_interval interval or scalar value. |
- Parameters
-
| [in,out] | other_interval | The interval or scalar value to compute the minimum distance with. |
- Returns
- The minimum distance between the current interval and the
other_interval interval or scalar value.
template<typename T = int>
template<typename U >
| constexpr auto recti::Interval< T >::min_dist_with |
( |
const U & |
other_interval | ) |
const -> T |
|
inlineconstexpr |
Computes the minimum distance between the current interval and the other_interval interval or scalar value.
This function returns the minimum distance between the current interval and the interval or scalar value represented by the other_interval parameter. If the other_interval parameter is less than the current interval, the function returns the distance between the lower bound of the current interval and the other_interval parameter. If the other_interval parameter is greater than the current interval, the function returns the distance between the upper bound of current interval and the other_interval parameter. If the other_interval parameter is within the current interval, the function returns 0.
- Template Parameters
-
| U | The type of the other_interval interval or scalar value. |
- Parameters
-
| [in] | other_interval | The interval or scalar value to compute the minimum distance with. |
- Returns
- The minimum distance between the current interval and the
other_interval interval or scalar value.
template<typename T = int>
template<typename U >
| constexpr auto recti::Interval< T >::operator<=> |
( |
const U & |
rhs | ) |
const -> std::weak_ordering |
|
inlineconstexpr |
Spaceship comparison operator for Interval objects.
Compares the upper bound (ub) of the Interval object on the left-hand side (LHS) with the value on the right-hand side (RHS). If the LHS upper bound is less than the RHS value, it returns std::weak_ordering::less. If the LHS lower bound is greater than the RHS value, it returns std::weak_ordering::greater. Otherwise, it returns std::weak_ordering::equivalent.
- Template Parameters
-
| U | The type of the value to compare against the interval bounds. |
- Parameters
-
| [in] | rhs | The value to compare against the interval bounds. |
- Returns
std::weak_ordering indicating the relationship between the interval and the value.
template<typename T = int>
template<class Stream >
| auto operator<< |
( |
Stream & |
out, |
|
|
const Interval< T > & |
intvl |
|
) |
| -> Stream& |
|
friend |
Overloads the stream insertion operator (<<) to print an Interval object to the given output stream.
This function allows Interval objects to be printed directly to an output stream, such as std::cout, by overloading the stream insertion operator (<<). The Interval object is printed in the format [lower_bound, upper_bound].
- Template Parameters
-
| Stream | The type of the output stream. |
- Parameters
-
| out | The output stream to write the Interval object to. |
| intvl | The Interval object to be printed. |
- Returns
- A reference to the output stream (
out) for chaining stream operations.
template<typename T = int>
| constexpr auto operator<=> |
( |
const T & |
lhs, |
|
|
const Interval< T > & |
rhs |
|
) |
| -> std::weak_ordering |
|
friend |
Spaceship comparison operator for comparing a value with an Interval object.
Compares the given value with the bounds of the Interval object on the right-hand side. If the value is less than the lower bound of the interval, it returns std::weak_ordering::less. If the value is greater than the upper bound of the interval, it returns std::weak_ordering::greater. Otherwise, it returns std::weak_ordering::equivalent.
- Template Parameters
-
| T | The type of the value to compare against the interval bounds. |
- Parameters
-
| [in] | lhs | The value to compare against the interval bounds. |
| [in] | rhs | The Interval object to compare the value against. |
- Returns
std::weak_ordering indicating the relationship between the value and the interval.