LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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.

45  : _window(start, end)
46  {
47  if (start > end) throw std::runtime_error("Inserted invalid range: end before start.");
48  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:91
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:91
template<class T>
void util::Range< T >::Merge ( const Range< T > &  a)
inline

Merge two util::Range into 1.

Definition at line 83 of file Range.h.

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

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

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

Definition at line 74 of file Range.h.

74 { 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().

68 { 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:91
template<class T>
bool util::Range< T >::operator< ( const T &  rhs) const
inline

Definition at line 79 of file Range.h.

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

79 { 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:91
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, util::Range< T >::End(), and util::Range< T >::Start().

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

Definition at line 69 of file Range.h.

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

69 { 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:91
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.

80 { 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:91
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, and e.

59  {
60  if (s >= e) throw std::runtime_error("Inserted invalid range: end before start.");
61  _window.first = s;
62  _window.second = e;
63  }
std::pair< T, T > _window
Protected to avoid user&#39;s illegal modification on first/second (sorry users!)
Definition: Range.h:91
Float_t e
Definition: plot.C:35
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:91

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: