Public Types | Public Member Functions | Protected Attributes | List of all members
lar::util::MinMaxCollector< T > Class Template Reference

Keeps track of the minimum and maximum value we observed. More...

#include <StatCollector.h>

Public Types

using Data_t = T
 type of data we collect More...
 
using This_t = MinMaxCollector< T >
 this type More...
 

Public Member Functions

bool has_data () const
 Returns whether at least one datum has been added. More...
 
Data_t min () const
 Returns the accumulated minimum, or a very large number if no values. More...
 
Data_t max () const
 Returns the accumulated maximum, or a very small number if no values. More...
 
void clear ()
 Removes all statistics and reinitializes the object. More...
 
template<typename Iter >
lar::util::MinMaxCollector< T > & add (Iter begin, Iter end)
 
 MinMaxCollector ()=default
 Default constructor: no data collected so far. More...
 
 MinMaxCollector (std::initializer_list< Data_t > init)
 Constructor: starts with parsing the specified data. More...
 
template<typename Iter >
 MinMaxCollector (Iter begin, Iter end)
 Include a sequence of values in the statistics. More...
 
Inserters
This_tadd (Data_t value)
 Include a single value in the statistics. More...
 
This_tadd (std::initializer_list< Data_t > values)
 Include a sequence of values in the statistics. More...
 
template<typename Iter >
This_tadd (Iter begin, Iter end)
 Include a sequence of values in the statistics. More...
 

Protected Attributes

Data_t minimum = std::numeric_limits<Data_t>::max()
 the accumulated minimum More...
 
Data_t maximum = std::numeric_limits<Data_t>::min()
 the accumulated maximum More...
 

Detailed Description

template<typename T>
class lar::util::MinMaxCollector< T >

Keeps track of the minimum and maximum value we observed.


Template Parameters
Ttype of datum

Implementation note: a similar class with an arbitrary comparison rule would require a careful choice of initial values for minimum and maximum, or a entry count that should be checked at each insertion. We save that slight overhead here.

Definition at line 748 of file StatCollector.h.

Member Typedef Documentation

template<typename T>
using lar::util::MinMaxCollector< T >::Data_t = T

type of data we collect

Definition at line 750 of file StatCollector.h.

template<typename T>
using lar::util::MinMaxCollector< T >::This_t = MinMaxCollector<T>

this type

Definition at line 751 of file StatCollector.h.

Constructor & Destructor Documentation

template<typename T>
lar::util::MinMaxCollector< T >::MinMaxCollector ( )
default

Default constructor: no data collected so far.

template<typename T>
lar::util::MinMaxCollector< T >::MinMaxCollector ( std::initializer_list< Data_t init)
inline

Constructor: starts with parsing the specified data.

Definition at line 758 of file StatCollector.h.

759  { add(init); }
This_t & add(Data_t value)
Include a single value in the statistics.
init
Definition: train.py:42
template<typename T>
template<typename Iter >
lar::util::MinMaxCollector< T >::MinMaxCollector ( Iter  begin,
Iter  end 
)
inline

Include a sequence of values in the statistics.

Template Parameters
Itertype of an iterator on values
Parameters
beginiterator pointing to the first value to be included
enditerator pointing to the last value to be included

Definition at line 768 of file StatCollector.h.

769  { add(begin, end); }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
This_t & add(Data_t value)
Include a single value in the statistics.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72

Member Function Documentation

template<typename T >
lar::util::MinMaxCollector< T > & lar::util::MinMaxCollector< T >::add ( Data_t  value)

Include a single value in the statistics.

Parameters
valuethe value to be added
Returns
this object

Definition at line 1090 of file StatCollector.h.

1091 {
1092  if (value < minimum) minimum = value;
1093  if (value > maximum) maximum = value;
1094  return *this;
1095 } // lar::util::MinMaxCollector<T>::add
Data_t minimum
the accumulated minimum
Data_t maximum
the accumulated maximum
template<typename T >
lar::util::MinMaxCollector< T > & lar::util::MinMaxCollector< T >::add ( std::initializer_list< Data_t values)
inline

Include a sequence of values in the statistics.

Parameters
valuesthe values to be added
Returns
this object

Definition at line 1100 of file StatCollector.h.

1101  { return add(values.begin(), values.end()); }
This_t & add(Data_t value)
Include a single value in the statistics.
Q_UINT16 values[128]
template<typename T>
template<typename Iter >
This_t& lar::util::MinMaxCollector< T >::add ( Iter  begin,
Iter  end 
)

Include a sequence of values in the statistics.

Template Parameters
Itertype of an iterator on values
Parameters
beginiterator pointing to the first value to be included
enditerator pointing to the last value to be included
Returns
this object
template<typename T>
template<typename Iter >
lar::util::MinMaxCollector<T>& lar::util::MinMaxCollector< T >::add ( Iter  begin,
Iter  end 
)
inline

Definition at line 1106 of file StatCollector.h.

1107 {
1108  std::for_each(begin, end, [this](Data_t value) { this->add(value); });
1109  return *this;
1110 } // lar::util::MinMaxCollector<T>::add(Iter)
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
This_t & add(Data_t value)
Include a single value in the statistics.
T Data_t
type of data we collect
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
template<typename T >
void lar::util::MinMaxCollector< T >::clear ( )
inline

Removes all statistics and reinitializes the object.

Definition at line 1114 of file StatCollector.h.

1114  {
1117 } // lar::util::MinMaxCollector<T>::clear()
Data_t minimum
the accumulated minimum
Data_t maximum
the accumulated maximum
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
template<typename T>
bool lar::util::MinMaxCollector< T >::has_data ( ) const
inline

Returns whether at least one datum has been added.

Definition at line 804 of file StatCollector.h.

804 { return minimum <= maximum; }
Data_t minimum
the accumulated minimum
Data_t maximum
the accumulated maximum
template<typename T>
Data_t lar::util::MinMaxCollector< T >::max ( ) const
inline

Returns the accumulated maximum, or a very small number if no values.

Definition at line 810 of file StatCollector.h.

810 { return maximum; }
Data_t maximum
the accumulated maximum
template<typename T>
Data_t lar::util::MinMaxCollector< T >::min ( ) const
inline

Returns the accumulated minimum, or a very large number if no values.

Definition at line 807 of file StatCollector.h.

807 { return minimum; }
Data_t minimum
the accumulated minimum

Member Data Documentation

template<typename T>
Data_t lar::util::MinMaxCollector< T >::maximum = std::numeric_limits<Data_t>::min()
protected

the accumulated maximum

Definition at line 821 of file StatCollector.h.

template<typename T>
Data_t lar::util::MinMaxCollector< T >::minimum = std::numeric_limits<Data_t>::max()
protected

the accumulated minimum

Definition at line 818 of file StatCollector.h.


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