thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.1.5
ThePEG::MaxCmp< T, Indx, Cmp > Class Template Reference

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>

Inheritance diagram for ThePEG::MaxCmp< T, Indx, Cmp >:

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. More...
 
 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;.
 
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.
 

Detailed Description

template<typename T = double, typename Indx = int, typename Cmp = std::greater<T>>
class ThePEG::MaxCmp< T, Indx, Cmp >

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.

Definition at line 31 of file MaxCmp.h.

Member Function Documentation

◆ operator()()

template<typename T = double, typename Indx = int, typename Cmp = std::greater<T>>
bool ThePEG::MaxCmp< T, Indx, Cmp >::operator() ( const T &  t,
Indx  i = Indx() 
)
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.


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