LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
util::Range< T > Class Template Reference

represents a "Range" w/ notion of ordering. A range is defined by a pair of "start" and "end" values. This is stored in std::pair
attribute util::Range::_window. This attribute is protected so that the start/end cannot
be changed w/o a check that start is always less than end. Note the specialization
requires a template class T to have less operator implemented.
More...

#include "Range.h"

Public Member Functions

 Range (const T &start, const T &end)
 Enforced ctor. start must be less than end. More...
 
 ~Range ()
 Default dtor. More...
 
const T & Start () const
 "start" accessor More...
 
const T & End () const
 "end" accessor More...
 
void Set (const T &s, const T &e)
 Setter. More...
 
bool operator< (const Range &rhs) const
 
bool operator> (const Range &rhs) const
 
bool operator== (const Range &rhs) const
 
bool operator!= (const Range &rhs) const
 
bool operator< (const T &rhs) const
 
bool operator> (const T &rhs) const
 
void Merge (const Range &a)
 Merge two util::Range into 1. More...
 

Protected Attributes

std::pair< T, T > _window
 Protected to avoid user's illegal modification on first/second (sorry users!) More...
 

Private Member Functions

 Range ()
 Default ctor is hidden. More...
 

Friends

class UniqueRangeSet< T >
 

Detailed Description

template<class T>
class util::Range< T >

represents a "Range" w/ notion of ordering. A range is defined by a pair of "start" and "end" values. This is stored in std::pair
attribute util::Range::_window. This attribute is protected so that the start/end cannot
be changed w/o a check that start is always less than end. Note the specialization
requires a template class T to have less operator implemented.

Definition at line 35 of file Range.h.

Constructor & Destructor Documentation

template<class T>
util::Range< T >::Range ( )
inlineprivate

Default ctor is hidden.

Definition at line 41 of file Range.h.

41 {}
template<class T>
util::Range< T >::Range ( const T &  start,
const T &  end 
)
inline

Enforced ctor. start must be less than end.

Definition at line 45 of file Range.h.

47  : _window(start,end)
48  { if(start>end) throw std::runtime_error("Inserted invalid range: end before start."); }
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:93
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
template<class T>
util::Range< T >::~Range ( )
inline

Default dtor.

Definition at line 51 of file Range.h.

51 {}

Member Function Documentation

template<class T>
const T& util::Range< T >::End ( ) const
inline

"end" accessor

Definition at line 56 of file Range.h.

References util::Range< T >::_window.

Referenced by util::Range< T >::Merge(), util::Range< T >::operator==(), and util::Range< T >::operator>().

56 { return _window.second; }
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:93
template<class T>
void util::Range< T >::Merge ( const Range< T > &  a)
inline

Merge two util::Range into 1.

Definition at line 86 of file Range.h.

References util::Range< T >::_window, util::Range< T >::End(), max, min, and util::Range< T >::Start().

Referenced by util::UniqueRangeSet< T >::emplace().

86  {
87  _window.first = std::min( _window.first, a.Start() );
88  _window.second = std::max( _window.second, a.End() );
89  }
Int_t max
Definition: plot.C:27
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:93
Int_t min
Definition: plot.C:26
template<class T>
bool util::Range< T >::operator!= ( const Range< T > &  rhs) const
inline

Definition at line 74 of file Range.h.

75  {return !( (*this) == rhs ); }
template<class T>
bool util::Range< T >::operator< ( const Range< T > &  rhs) const
inline

Definition at line 68 of file Range.h.

References util::Range< T >::_window, and util::Range< T >::Start().

69  {return ( _window.second < rhs.Start() ); }
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:93
template<class T>
bool util::Range< T >::operator< ( const T &  rhs) const
inline

Definition at line 80 of file Range.h.

References util::Range< T >::_window.

81  {return (_window.second < rhs); }
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:93
template<class T>
bool util::Range< T >::operator== ( const Range< T > &  rhs) const
inline

Definition at line 72 of file Range.h.

References util::Range< T >::_window, util::Range< T >::End(), and util::Range< T >::Start().

73  {return ( _window.first == rhs.Start() && _window.second == rhs.End() ); }
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:93
template<class T>
bool util::Range< T >::operator> ( const Range< T > &  rhs) const
inline

Definition at line 70 of file Range.h.

References util::Range< T >::_window, and util::Range< T >::End().

71  {return ( _window.first > rhs.End() ); }
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:93
template<class T>
bool util::Range< T >::operator> ( const T &  rhs) const
inline

Definition at line 82 of file Range.h.

References util::Range< T >::_window.

83  {return (_window.first > rhs); }
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:93
template<class T>
void util::Range< T >::Set ( const T &  s,
const T &  e 
)
inline

Setter.

Definition at line 58 of file Range.h.

References util::Range< T >::_window, e, and s.

59  {
60  if(s>=e) throw std::runtime_error("Inserted invalid range: end before start.");
61  _window.first = s;
62  _window.second = e;
63  }
Float_t s
Definition: plot.C:23
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:93
Float_t e
Definition: plot.C:34
template<class T>
const T& util::Range< T >::Start ( ) const
inline

"start" accessor

Definition at line 54 of file Range.h.

References util::Range< T >::_window.

Referenced by util::Range< T >::Merge(), util::Range< T >::operator<(), and util::Range< T >::operator==().

54 { return _window.first; }
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:93

Friends And Related Function Documentation

template<class T>
friend class UniqueRangeSet< T >
friend

Definition at line 37 of file Range.h.

Member Data Documentation

template<class T>
std::pair<T,T> util::Range< T >::_window
protected

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