Main Page · Modules · All Classes · Class Hierarchy
Public Member Functions | Private Attributes | List of all members
MCSamples< T > Struct Template Reference

Sample cache class. More...

#include <MCSamples.hpp>

Public Member Functions

 MCSamples (int size, MCSampleStatistic< T > &statistic)
 Class constructor. More...
 
 MCSamples (const MCSamples &other)
 Class copy constructor. More...
 
virtual ~MCSamples ()
 Class destructor.
 
int GetSize () const
 Get the size of the sample cache. More...
 
bool IsEmpty () const
 Check if the sample cache is empty. More...
 
bool IsValid () const
 Check if the sample cache is valid for calculations. More...
 
int GetSampleCount () const
 Get the sample count in the cache. More...
 
void AddStatistic (MCSampleStatistic< T > &statistic)
 Add a statistic calculation. More...
 
MCSampleStatistic< T > & GetDefaultStatistic ()
 Get the default (first) statistic. More...
 
MCSampleStatistic< T > * GetStatistic (const std::string &statistic_name)
 Get a statistic by name. More...
 
void RemoveStatistic (MCSampleStatistic< T > &statistic)
 Remove a statistic calculation. More...
 
void Reset ()
 Get the size of the sample cache. More...
 
void ClearStatistics ()
 Clear the statistics of the sample cache.
 
template<typename U >
void AddValues (const U &container)
 Put a whole container into the cache. More...
 
MCSamples< T > & operator= (const MCSamples< T > &other)
 Copy assignment operator. More...
 
bool operator== (const MCSamples< T > &other) const
 Equality (==) operator. More...
 
bool operator!= (const MCSamples< T > &other) const
 Inequality (!=) operator. More...
 
MCSamples< T > & operator<< (const T value)
 Bitwise left shift (<<) operator. More...
 
MCSamples< T > & operator<< (const std::vector< T > &container)
 Bitwise left shift (<<) operator. More...
 
MCSamples< T > & operator<< (const std::pair< const T, float > &value)
 Bitwise left shift (<<) operator. More...
 
const MCSamples< T > operator+ (const T value) const
 Increment (+) operator. More...
 
const MCSamples< T > operator+ (const std::pair< const T, float > &value) const
 Increment (+) operator. More...
 
MCSamples< T > & operator+= (const T value)
 Addition assignment (+=) operator. More...
 
MCSamples< T > & operator+= (const std::vector< T > &container)
 Addition assignment (+=) operator. More...
 
MCSamples< T > & operator+= (const std::pair< const T, float > &value)
 Addition assignment (+=) operator. More...
 

Private Attributes

T * Samples
 Sample storage.
 
float * Weights
 Weight storage.
 
int Size
 The size of the sample cache.
 
bool Valid
 Whenever the sample cache has been filled at least once to do calculations.
 
int LastElementIndex
 Last element index in the cache.
 
MC::Statistic< T >::List Statistics
 The list of the calculated statistics for the sample cache.
 

Detailed Description

template<typename T>
struct MCSamples< T >

Sample cache class.

Definition at line 52 of file MCSamples.hpp.

Constructor & Destructor Documentation

template<typename T>
MCSamples< T >::MCSamples ( int  size,
MCSampleStatistic< T > &  statistic 
)
inlineexplicit

Class constructor.

Parameters
sizeSample cache size
statisticSample statistic

Definition at line 63 of file MCSamples.hpp.

template<typename T>
MCSamples< T >::MCSamples ( const MCSamples< T > &  other)
inline

Class copy constructor.

Parameters
otherOther instance

Definition at line 76 of file MCSamples.hpp.

Member Function Documentation

template<typename T>
void MCSamples< T >::AddStatistic ( MCSampleStatistic< T > &  statistic)
inline

Add a statistic calculation.

Parameters
statisticNew statistic for the cache

The statistic will be owned by the sample cache and destroyed when the cache is deleted.

Definition at line 159 of file MCSamples.hpp.

template<typename T>
template<typename U >
void MCSamples< T >::AddValues ( const U &  container)
inline

Put a whole container into the cache.

Parameters
containerContainer

Definition at line 260 of file MCSamples.hpp.

template<typename T>
MCSampleStatistic<T>& MCSamples< T >::GetDefaultStatistic ( )
inline

Get the default (first) statistic.

Returns
Default statistic.

Definition at line 174 of file MCSamples.hpp.

template<typename T>
int MCSamples< T >::GetSampleCount ( ) const
inline

Get the sample count in the cache.

Returns
Sample count

Definition at line 136 of file MCSamples.hpp.

template<typename T>
int MCSamples< T >::GetSize ( ) const
inline

Get the size of the sample cache.

Returns
Size of the sample cache

Definition at line 98 of file MCSamples.hpp.

template<typename T>
MCSampleStatistic<T>* MCSamples< T >::GetStatistic ( const std::string &  statistic_name)
inline

Get a statistic by name.

Parameters
statistic_nameStatistic name
Returns
Statistic if it exists otherwise NULL.

Definition at line 188 of file MCSamples.hpp.

template<typename T>
bool MCSamples< T >::IsEmpty ( ) const
inline

Check if the sample cache is empty.

Returns
True if empty otherwise false.

Definition at line 110 of file MCSamples.hpp.

template<typename T>
bool MCSamples< T >::IsValid ( ) const
inline

Check if the sample cache is valid for calculations.

Returns
True if valid otherwise false.

The cache reaches this state after it is filled.

Definition at line 124 of file MCSamples.hpp.

template<typename T>
bool MCSamples< T >::operator!= ( const MCSamples< T > &  other) const
inline

Inequality (!=) operator.

Parameters
otherOther sample cache to be compared
Returns
True if the instances are not equal.

Definition at line 351 of file MCSamples.hpp.

template<typename T>
const MCSamples<T> MCSamples< T >::operator+ ( const T  value) const
inline

Increment (+) operator.

Parameters
valueValue
Returns
Reference to the current instance.

The oldest element is dropped out of the sample cache and the new value is included.

Definition at line 420 of file MCSamples.hpp.

template<typename T>
const MCSamples<T> MCSamples< T >::operator+ ( const std::pair< const T, float > &  value) const
inline

Increment (+) operator.

Parameters
valueValue
Returns
Reference to the current instance.

The oldest element is dropped out of the sample cache and the new value is included.

Definition at line 437 of file MCSamples.hpp.

template<typename T>
MCSamples<T>& MCSamples< T >::operator+= ( const T  value)
inline

Addition assignment (+=) operator.

Parameters
valueValue
Returns
Reference to the current instance.

The oldest element is dropped out of the sample cache and the new value is included.

Definition at line 454 of file MCSamples.hpp.

template<typename T>
MCSamples<T>& MCSamples< T >::operator+= ( const std::vector< T > &  container)
inline

Addition assignment (+=) operator.

Parameters
containerVector container
Returns
Reference to the current instance.

The oldest element is dropped out of the sample cache and the new value is included.

Definition at line 471 of file MCSamples.hpp.

template<typename T>
MCSamples<T>& MCSamples< T >::operator+= ( const std::pair< const T, float > &  value)
inline

Addition assignment (+=) operator.

Parameters
valueValue
Returns
Reference to the current instance.

The oldest element is dropped out of the sample cache and the new value is included.

Definition at line 493 of file MCSamples.hpp.

template<typename T>
MCSamples<T>& MCSamples< T >::operator<< ( const std::vector< T > &  container)
inline

Bitwise left shift (<<) operator.

Parameters
containerVector container
Returns
Reference to the current instance.

The oldest element is dropped out of the sample cache and the new value is included.

Definition at line 385 of file MCSamples.hpp.

template<typename T>
MCSamples<T>& MCSamples< T >::operator<< ( const T  value)
inline

Bitwise left shift (<<) operator.

Parameters
valueValue
Returns
Reference to the current instance.

The oldest element is dropped out of the sample cache and the new value is included.

Definition at line 368 of file MCSamples.hpp.

template<typename T>
MCSamples<T>& MCSamples< T >::operator<< ( const std::pair< const T, float > &  value)
inline

Bitwise left shift (<<) operator.

Parameters
valueValue
Returns
Reference to the current instance.

The oldest element is dropped out of the sample cache and the new value is included.

Definition at line 403 of file MCSamples.hpp.

template<typename T>
MCSamples<T>& MCSamples< T >::operator= ( const MCSamples< T > &  other)
inline

Copy assignment operator.

Parameters
otherOther sample cache to be assigned
Returns
Reference to the current instance

Definition at line 277 of file MCSamples.hpp.

template<typename T>
bool MCSamples< T >::operator== ( const MCSamples< T > &  other) const
inline

Equality (==) operator.

Parameters
otherOther sample cache to be compared
Returns
True if the instances are equal.

Definition at line 323 of file MCSamples.hpp.

template<typename T>
void MCSamples< T >::RemoveStatistic ( MCSampleStatistic< T > &  statistic)
inline

Remove a statistic calculation.

Parameters
statisticA statistic to be removed from the cache

The statistic will not be owned by the cache anymore and must be deleted manually.

Definition at line 208 of file MCSamples.hpp.

template<typename T>
void MCSamples< T >::Reset ( )
inline

Get the size of the sample cache.

Returns
The sample cache size

Definition at line 227 of file MCSamples.hpp.


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