Emergency 20 Dokumentation  4.2.0
em5::RandomEnumerator< T > Class Template Reference

Helper class for iterating over a list of instances of a specific type, in a random order. More...

#include <RandomEnumerator.h>

Inheritance diagram for em5::RandomEnumerator< T >:
em5::ComponentsRandomEnumerator< T >

Public Member Functions

 RandomEnumerator (const std::vector< T * > &inputToCopy, uint32 maxTries=std::numeric_limits< uint32 >::max())
 Constructor to pass a vector of elements, which will be copied. More...
 
 RandomEnumerator (constructionpolicy::Policy policy, std::vector< T * > &inputToSwapWith, uint32 maxTries=std::numeric_limits< uint32 >::max())
 Constructor to pass a vector of elements, with the option to swap contents. More...
 
 RandomEnumerator (std::vector< T * > &inputToCopy, uint32 maxTries=std::numeric_limits< uint32 >::max())
 
bool empty () const
 Check if all elements were read out already. More...
 
T * getNext ()
 Randomly choose an element that was not returned before. More...
 

Protected Member Functions

 RandomEnumerator (uint32 maxTries=std::numeric_limits< uint32 >::max())
 

Protected Attributes

std::vector< T * > mElements
 
uint32 mTriesLeft
 

Detailed Description

template<typename T>
class em5::RandomEnumerator< T >

Helper class for iterating over a list of instances of a specific type, in a random order.

Remarks
No element will be returned twice

Constructor & Destructor Documentation

template<typename T >
em5::RandomEnumerator< T >::RandomEnumerator ( const std::vector< T * > &  inputToCopy,
uint32  maxTries = std::numeric_limits<uint32>::max() 
)
inlineexplicit

Constructor to pass a vector of elements, which will be copied.

template<typename T >
em5::RandomEnumerator< T >::RandomEnumerator ( constructionpolicy::Policy  policy,
std::vector< T * > &  inputToSwapWith,
uint32  maxTries = std::numeric_limits<uint32>::max() 
)
inline

Constructor to pass a vector of elements, with the option to swap contents.

template<typename T >
em5::RandomEnumerator< T >::RandomEnumerator ( std::vector< T * > &  inputToCopy,
uint32  maxTries = std::numeric_limits<uint32>::max() 
)
inlineexplicit
template<typename T >
em5::RandomEnumerator< T >::RandomEnumerator ( uint32  maxTries = std::numeric_limits<uint32>::max())
inlineexplicitprotected

Member Function Documentation

template<typename T >
bool em5::RandomEnumerator< T >::empty ( ) const
inline

Check if all elements were read out already.

template<typename T >
T* em5::RandomEnumerator< T >::getNext ( )
inline

Randomly choose an element that was not returned before.

Returns
Pointer to another element, which gets randomly chosen from the list; or a null pointer in case we already had all elements

Member Data Documentation

template<typename T >
std::vector<T*> em5::RandomEnumerator< T >::mElements
protected
template<typename T >
uint32 em5::RandomEnumerator< T >::mTriesLeft
protected

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