CMS 3D CMS Logo

List of all members | Public Member Functions
TRange< T > Class Template Reference

#include <TRange.h>

Inheritance diagram for TRange< T >:

Public Member Functions

bool empty () const
 true for empty region. note that region [x,x] is not empty More...
 
bool inside (const T &value) const
 check if object is inside region More...
 
const Tmax () const
 upper edge of range More...
 
T mean () const
 
const Tmin () const
 lower edge of range More...
 
void sort ()
 
TRange< Tsum (const TRange< T > &r) const
 sum of overlaping regions. the overlapping should be checked before. More...
 
 TRange ()
 
 TRange (const T &aMin, const T &aMax)
 
 TRange (const std::pair< T, T > &apair)
 

Detailed Description

template<class T>
class TRange< T >

Define a range [aMin,aMax]

Definition at line 11 of file TRange.h.

Constructor & Destructor Documentation

◆ TRange() [1/3]

template<class T>
TRange< T >::TRange ( )
inline

Definition at line 13 of file TRange.h.

Referenced by TRange< int >::sum().

13 {}

◆ TRange() [2/3]

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

Definition at line 15 of file TRange.h.

15 : std::pair<T, T>(aMin, aMax) {}

◆ TRange() [3/3]

template<class T>
TRange< T >::TRange ( const std::pair< T, T > &  apair)
inline

Definition at line 17 of file TRange.h.

17 : std::pair<T, T>(apair) {}

Member Function Documentation

◆ empty()

template<class T>
bool TRange< T >::empty ( ) const
inline

true for empty region. note that region [x,x] is not empty

Definition at line 28 of file TRange.h.

Referenced by TRange< int >::sort(), and TRange< int >::sum().

28 { return (this->second < this->first); }

◆ inside()

template<class T>
bool TRange< T >::inside ( const T value) const
inline

check if object is inside region

Definition at line 31 of file TRange.h.

31  {
32  if (value < this->first || this->second < value)
33  return false;
34  else
35  return true;
36  }
U second(std::pair< T, U > const &p)
Definition: value.py:1

◆ max()

template<class T>
const T& TRange< T >::max ( ) const
inline

upper edge of range

Definition at line 23 of file TRange.h.

Referenced by PixelToLNKAssociateFromAscii::addConnections(), and TRange< int >::sum().

23 { return this->second; }
U second(std::pair< T, U > const &p)

◆ mean()

template<class T>
T TRange< T >::mean ( ) const
inline

Definition at line 25 of file TRange.h.

25 { return (this->first + this->second) / 2.; }
U second(std::pair< T, U > const &p)

◆ min()

template<class T>
const T& TRange< T >::min ( ) const
inline

lower edge of range

Definition at line 20 of file TRange.h.

Referenced by PixelToLNKAssociateFromAscii::addConnections(), and TRange< int >::sum().

20 { return this->first; }

◆ sort()

template<class T>
void TRange< T >::sort ( )
inline

Definition at line 61 of file TRange.h.

61  {
62  if (empty())
63  std::swap(this->first, this->second);
64  }
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
U second(std::pair< T, U > const &p)
bool empty() const
true for empty region. note that region [x,x] is not empty
Definition: TRange.h:28

◆ sum()

template<class T>
TRange<T> TRange< T >::sum ( const TRange< T > &  r) const
inline

sum of overlaping regions. the overlapping should be checked before.

Definition at line 52 of file TRange.h.

52  {
53  if (this->empty())
54  return r;
55  else if (r.empty())
56  return *this;
57  else
58  return TRange((min() < r.min()) ? min() : r.min(), (max() < r.max()) ? r.max() : max());
59  }
const T & max() const
upper edge of range
Definition: TRange.h:23
TRange()
Definition: TRange.h:13
const T & min() const
lower edge of range
Definition: TRange.h:20
bool empty() const
true for empty region. note that region [x,x] is not empty
Definition: TRange.h:28