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.
 MaxRecorder (Type const &maxValue, Payload const &payload)
 This constructor allows the user to explicitly set the starting maxValue, and the default payload.
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().

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

This constructor allows the user to explicitly set the starting maxValue, and the default payload.

Definition at line 47 of file maxRecorder.h.


Member Function Documentation

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 85 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 97 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 105 of file maxRecorder.h.

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

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 67 of file maxRecorder.h.


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

Generated on Wed Nov 25 00:42:49 2009 for dlrUtilities Utility Library by  doxygen 1.5.8