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

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

#include <minRecorder.h>

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

List of all members.

Public Member Functions

 MinRecorder ()
 Default constructor initializes min to a very large number (std::numeric_limits<Type>::max()), and sets the payload to it's default value.
 MinRecorder (Type const &minValue, Payload const &payload)
 This constructor allows the user to explicitly set the starting minValue, and the default payload.
bool test (const Type &value, const Payload &payload)
 This member function compares its first argument with the saved minimum value, and updates the saved minimum (and payload) if the argument is larger.
const Type & getMin ()
 This member function returns the saved minimum.
const Payload & getPayload ()
 This member function returns the saved "payload".
void reset ()
 This member function resets the saved minimum just as if *this were freshly constructed with the default constructor.


Detailed Description

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

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

WARNING: This interface may change slightly in subsequent releases.

Definition at line 30 of file minRecorder.h.


Constructor & Destructor Documentation

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

Default constructor initializes min to a very large number (std::numeric_limits<Type>::max()), and sets the payload to it's default value.

Definition at line 38 of file minRecorder.h.

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

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

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

Definition at line 45 of file minRecorder.h.


Member Function Documentation

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

This member function returns the saved minimum.

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 83 of file minRecorder.h.

template<class Type , class Payload >
const Payload& dlr::numeric::MinRecorder< 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 95 of file minRecorder.h.

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

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

Definition at line 103 of file minRecorder.h.

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

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

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

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

Definition at line 65 of file minRecorder.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