dlr::numeric::MaxRecorder< Type, Payload > Class Template Reference

A simple class template to help you avoid writing "if(myVar > maxVal) {maxVal = myVar; bestIndex = ii;} all over your code. More...

#include <maxRecorder.h>

Collaboration diagram for dlr::numeric::MaxRecorder< Type, Payload >:
[legend]

List of all members.

Public Member Functions

 MaxRecorder ()
 Default constructor initializes max to a very small number (either std::numeric_limits<Type>::min(), -stdnumeric_limits<Type>::max(), depending on the signedness of Type), and sets the payload to it's default value.
bool test (const Type &value, const Payload &payload)
 This member function compares its first argument with the saved maximum value, and updates the saved maximum (and payload) if the argument is larger.
const Type & getMax ()
 This member function returns the saved maximum.
const Payload & getPayload ()
 This member function returns the saved "payload".
void reset ()
 This member function resets the saved maximum just as if *this were freshly constructed with the default constructor.


Detailed Description

template<class Type, class Payload>
class dlr::numeric::MaxRecorder< Type, Payload >

A simple class template to help you avoid writing "if(myVar > maxVal) {maxVal = myVar; bestIndex = ii;} all over your code.

WARNING: This interface may change slightly in subsequent releases.

Definition at line 30 of file maxRecorder.h.


Constructor & Destructor Documentation

template<class Type, class Payload>
dlr::numeric::MaxRecorder< Type, Payload >::MaxRecorder (  )  [inline]

Default constructor initializes max to a very small number (either std::numeric_limits<Type>::min(), -stdnumeric_limits<Type>::max(), depending on the signedness of Type), and sets the payload to it's default value.

Definition at line 40 of file maxRecorder.h.

References dlr::numeric::MaxRecorder< Type, Payload >::reset().


Member Function Documentation

template<class Type, class Payload>
bool dlr::numeric::MaxRecorder< Type, Payload >::test ( const Type &  value,
const Payload &  payload 
) [inline]

This member function compares its first argument with the saved maximum value, and updates the saved maximum (and payload) if the argument is larger.

Parameters:
value This argument will be compared to the saved maximum, and copied into the saved maximum if doing so will increase the saved maximum.
payload This argument is copied into the saved payload if and only if the saved maximum was updated.
Returns:
The return value is true if the saved maximum was updated, false otherwise.

Definition at line 59 of file maxRecorder.h.

template<class Type, class Payload>
const Type& dlr::numeric::MaxRecorder< Type, Payload >::getMax (  )  [inline]

This member function returns the saved maximum.

Returns:
The return value is the largest value passed to member function test() since construction, or since the last call to member function reset().

Definition at line 77 of file maxRecorder.h.

template<class Type, class Payload>
const Payload& dlr::numeric::MaxRecorder< Type, Payload >::getPayload (  )  [inline]

This member function returns the saved "payload".

Returns:
The return value is the payload associated with the largest value passed to member function test() since construction, or since the last call to member function reset().

Definition at line 89 of file maxRecorder.h.

template<class Type, class Payload>
void dlr::numeric::MaxRecorder< Type, Payload >::reset (  )  [inline]

This member function resets the saved maximum just as if *this were freshly constructed with the default constructor.

Definition at line 97 of file maxRecorder.h.

Referenced by dlr::numeric::MaxRecorder< Type, Payload >::MaxRecorder().


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

Generated on Tue Jan 6 17:52:08 2009 for dlrUtilities Utility Library by  doxygen 1.5.6