Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Phyth::Interval< UnitT > Struct Template Reference

Closed interval [min, max] of physical quantities. More...

#include <Interval.hpp>

Public Member Functions

 Interval (Quantity< UnitT > value) noexcept
 Construct a zero-length interval containing a single value.
 
 Interval (Quantity< UnitT > min, Quantity< UnitT > max)
 Construct a closed interval [min, max].
 
bool Contains (Quantity< UnitT > x) const noexcept
 Check if a value lies within the interval.
 
bool Contains (const Interval &interval) const noexcept
 Check if another interval is fully contained in this one.
 
Quantity< UnitT > GetMinimum () const noexcept
 
Quantity< UnitT > GetMaximum () const noexcept
 

Private Attributes

Quantity< UnitT > min_
 
Quantity< UnitT > max_
 

Detailed Description

template<typename UnitT>
struct Phyth::Interval< UnitT >

Closed interval [min, max] of physical quantities.

Template Parameters
UnitTThe unit type of the bounds

Example: Interval<Meter> temp(200_m, 400_m); if (temp.Contains(300_m)) { ... }

Definition at line 20 of file Interval.hpp.

Constructor & Destructor Documentation

◆ Interval() [1/2]

template<typename UnitT >
Phyth::Interval< UnitT >::Interval ( Quantity< UnitT >  value)
inlinenoexcept

Construct a zero-length interval containing a single value.

Parameters
valueThe only value in the interval

Definition at line 28 of file Interval.hpp.

◆ Interval() [2/2]

template<typename UnitT >
Phyth::Interval< UnitT >::Interval ( Quantity< UnitT >  min,
Quantity< UnitT >  max 
)
inline

Construct a closed interval [min, max].

Parameters
minLower bound (inclusive)
maxUpper bound (inclusive)
Exceptions
std::invalid_argumentif min > max

Definition at line 39 of file Interval.hpp.

Member Function Documentation

◆ Contains() [1/2]

template<typename UnitT >
bool Phyth::Interval< UnitT >::Contains ( const Interval< UnitT > &  interval) const
inlinenoexcept

Check if another interval is fully contained in this one.

Parameters
intervalThe interval to test
Returns
true if interval.max <= this.max && interval.min >= this.min

Definition at line 62 of file Interval.hpp.

◆ Contains() [2/2]

template<typename UnitT >
bool Phyth::Interval< UnitT >::Contains ( Quantity< UnitT >  x) const
inlinenoexcept

Check if a value lies within the interval.

Parameters
xThe value to test
Returns
true if min <= x <= max, false otherwise

Definition at line 52 of file Interval.hpp.

◆ GetMaximum()

template<typename UnitT >
Quantity< UnitT > Phyth::Interval< UnitT >::GetMaximum ( ) const
inlinenoexcept
Returns
Upper bound of the interval (inclusive)

Definition at line 70 of file Interval.hpp.

◆ GetMinimum()

template<typename UnitT >
Quantity< UnitT > Phyth::Interval< UnitT >::GetMinimum ( ) const
inlinenoexcept
Returns
Lower bound of the interval (inclusive)

Definition at line 67 of file Interval.hpp.

Member Data Documentation

◆ max_

template<typename UnitT >
Quantity<UnitT> Phyth::Interval< UnitT >::max_
private

Definition at line 74 of file Interval.hpp.

◆ min_

template<typename UnitT >
Quantity<UnitT> Phyth::Interval< UnitT >::min_
private

Definition at line 73 of file Interval.hpp.


The documentation for this struct was generated from the following file: