MaxCmp is a helper class to be used in a loop where one would like to keep track of the largest value so far of a certain expression. More...
#include <MaxCmp.h>
Public Member Functions | |
MaxCmp () | |
The default constructor. | |
MaxCmp (const T &t, Indx in=Indx()) | |
Constructor specifying an initial maximum value, t. | |
bool | operator() (const T &t, Indx i=Indx()) |
If t is the largest value seen so far return true. | |
operator const T & () const | |
Return the largest value so far. | |
const T & | value () const |
Return the largest value so far. | |
Indx | index () const |
Return the index of the largest object seen so far. | |
bool | operator! () const |
Return true if no index has been chosen. | |
Private Attributes | |
bool | init |
True if a first value has been given;. | |
T | max |
The largest value seen so far. | |
Indx | indx |
The index for the largest value seen so far. | |
Cmp | cmp |
The comparison object to be used. | |
MaxCmp is a helper class to be used in a loop where one would like to keep track of the largest value so far of a certain expression.
The class simply checks if the given value to the operator() is the largest so far (in which case true is returned, and the value is saved together with the optional index argument. The Cmp template argument is by default greater<T>, but can be set to any comparison class to change the meaning of maximum: MaxCmp<double, int, less<double> > will keep track of the smallest value.
|
inline |
|
inline |
|
inline |
Return the index of the largest object seen so far.
Definition at line 75 of file MaxCmp.h.
References ThePEG::MaxCmp< T, Indx, Cmp >::indx.
|
inline |
Return the largest value so far.
Definition at line 65 of file MaxCmp.h.
References ThePEG::MaxCmp< T, Indx, Cmp >::value().
|
inline |
Return true if no index has been chosen.
Definition at line 82 of file MaxCmp.h.
References ThePEG::MaxCmp< T, Indx, Cmp >::init.
|
inline |
If t is the largest value seen so far return true.
Otherwise return false. i is an optional index for the value t.
Definition at line 51 of file MaxCmp.h.
References ThePEG::MaxCmp< T, Indx, Cmp >::cmp, ThePEG::MaxCmp< T, Indx, Cmp >::indx, ThePEG::MaxCmp< T, Indx, Cmp >::init, and ThePEG::MaxCmp< T, Indx, Cmp >::max.
|
inline |
Return the largest value so far.
Definition at line 70 of file MaxCmp.h.
References ThePEG::MaxCmp< T, Indx, Cmp >::max.
Referenced by ThePEG::MaxCmp< T, Indx, Cmp >::operator const T &().
|
private |
The comparison object to be used.
Definition at line 106 of file MaxCmp.h.
Referenced by ThePEG::MaxCmp< T, Indx, Cmp >::operator()().
|
private |
The index for the largest value seen so far.
Definition at line 101 of file MaxCmp.h.
Referenced by ThePEG::MaxCmp< T, Indx, Cmp >::index(), and ThePEG::MaxCmp< T, Indx, Cmp >::operator()().
|
private |
True if a first value has been given;.
Definition at line 91 of file MaxCmp.h.
Referenced by ThePEG::MaxCmp< T, Indx, Cmp >::operator!(), and ThePEG::MaxCmp< T, Indx, Cmp >::operator()().
|
private |
The largest value seen so far.
Definition at line 96 of file MaxCmp.h.
Referenced by ThePEG::MaxCmp< T, Indx, Cmp >::operator()(), and ThePEG::MaxCmp< T, Indx, Cmp >::value().