KiCad PCB EDA Suite
RANGE< T > Class Template Reference

#include <range.h>

Public Member Functions

 RANGE (T aMin, T aMax)
 
 RANGE ()
 
MinV () const
 
MaxV () const
 
void Set (T aMin, T aMax) const
 
void Grow (T aValue)
 
bool Inside (const T &aValue) const
 
bool Overlaps (const RANGE< T > &aOther) const
 
bool Defined () const
 

Private Attributes

m_min
 
m_max
 
bool m_defined
 

Detailed Description

template<class T>
class RANGE< T >

Definition at line 25 of file range.h.

Constructor & Destructor Documentation

template<class T>
RANGE< T >::RANGE ( aMin,
aMax 
)
inline

Definition at line 28 of file range.h.

28  :
29  m_min( aMin ),
30  m_max( aMax ),
31  m_defined( true ) {}
T m_max
Definition: range.h:89
bool m_defined
Definition: range.h:90
T m_min
Definition: range.h:89
template<class T>
RANGE< T >::RANGE ( )
inline

Definition at line 33 of file range.h.

33  :
34  m_defined( false ) {}
bool m_defined
Definition: range.h:90

Member Function Documentation

template<class T>
bool RANGE< T >::Defined ( ) const
inline

Definition at line 83 of file range.h.

References RANGE< T >::m_defined.

84  {
85  return m_defined;
86  }
bool m_defined
Definition: range.h:90
template<class T>
void RANGE< T >::Grow ( aValue)
inline

Definition at line 52 of file range.h.

References RANGE< T >::m_defined, RANGE< T >::m_max, RANGE< T >::m_min, max, and min.

53  {
54  if( !m_defined )
55  {
56  m_min = aValue;
57  m_max = aValue;
58  m_defined = true;
59  }
60  else
61  {
62  m_min = std::min( m_min, aValue );
63  m_max = std::max( m_max, aValue );
64  }
65  }
T m_max
Definition: range.h:89
#define max(a, b)
Definition: auxiliary.h:86
bool m_defined
Definition: range.h:90
T m_min
Definition: range.h:89
#define min(a, b)
Definition: auxiliary.h:85
template<class T>
bool RANGE< T >::Inside ( const T &  aValue) const
inline

Definition at line 67 of file range.h.

References RANGE< T >::m_defined, RANGE< T >::m_max, and RANGE< T >::m_min.

68  {
69  if( !m_defined )
70  return true;
71 
72  return aValue >= m_min && aValue <= m_max;
73  }
T m_max
Definition: range.h:89
bool m_defined
Definition: range.h:90
T m_min
Definition: range.h:89
template<class T>
T RANGE< T >::MaxV ( ) const
inline

Definition at line 41 of file range.h.

References RANGE< T >::m_max.

42  {
43  return m_max;
44  }
T m_max
Definition: range.h:89
template<class T>
T RANGE< T >::MinV ( ) const
inline

Definition at line 36 of file range.h.

References RANGE< T >::m_min.

37  {
38  return m_min;
39  }
T m_min
Definition: range.h:89
template<class T>
bool RANGE< T >::Overlaps ( const RANGE< T > &  aOther) const
inline

Definition at line 75 of file range.h.

References RANGE< T >::m_defined, RANGE< T >::m_max, and RANGE< T >::m_min.

76  {
77  if( !m_defined || !aOther.m_defined )
78  return true;
79 
80  return m_max >= aOther.m_min && m_min <= aOther.m_max;
81  }
T m_max
Definition: range.h:89
bool m_defined
Definition: range.h:90
T m_min
Definition: range.h:89
template<class T>
void RANGE< T >::Set ( aMin,
aMax 
) const
inline

Definition at line 46 of file range.h.

References RANGE< T >::m_max, and RANGE< T >::m_min.

47  {
48  m_max = aMax;
49  m_min = aMin;
50  }
T m_max
Definition: range.h:89
T m_min
Definition: range.h:89

Member Data Documentation

template<class T>
bool RANGE< T >::m_defined
private
template<class T>
T RANGE< T >::m_max
private
template<class T>
T RANGE< T >::m_min
private

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