Emergency 2017 Dokumentation  v3.0.1
qsf::Random Class Reference

Static random number generation helper class. More...

#include <Random.h>

Public Member Functions

template<typename T , typename S >
const std::map< T, S >::const_iterator getAnyOf (const std::map< T, S > &container)
 
template<typename T , typename S >
const std::unordered_map< T, S >::const_iterator getAnyOf (const std::unordered_map< T, S > &container)
 
template<typename T , typename S >
const boost::container::flat_map< T, S >::const_iterator getAnyOf (const boost::container::flat_map< T, S > &container)
 
template<typename T , typename S >
const std::map< T, S >::const_iterator getAnyOf (const std::map< T, S > &container, const T &fallbackIfEmpty)
 
template<typename T , typename S >
const std::unordered_map< T, S >::const_iterator getAnyOf (const std::unordered_map< T, S > &container, const T &fallbackIfEmpty)
 
template<typename T , typename S >
const boost::container::flat_map< T, S >::const_iterator getAnyOf (const boost::container::flat_map< T, S > &container, const T &fallbackIfEmpty)
 

Static Public Member Functions

static float getRandomFloat (float minimum, float maximum)
 Returns a random floating point value in the range [min...max], that is including min and max as possible values. More...
 
static int32 getRandomInt (int32 minimum, int32 maximum)
 Returns a random signed integer in the range [min...max], that is including min and max as possible values. More...
 
static uint32 getRandomUint (uint32 minimum, uint32 maximum)
 Returns a random unsigned integer in the range [min...max], that is including min and max as possible values. More...
 
static bool getRandomChance (float chance)
 
template<typename RandomAccessIterator >
static RandomAccessIterator getAnyOf (RandomAccessIterator begin, RandomAccessIterator end)
 Get any of container. More...
 
template<typename T >
static const T & getAnyOf (const std::vector< T > &container)
 Get any of std::vector container. More...
 
template<typename T >
static const T & getAnyOf (const std::vector< T > &container, const T &fallbackIfEmpty)
 Get any of std::vector container. More...
 
template<typename T >
static const T & getAnyOf (const std::set< T > &container)
 Get any of std::set container. More...
 
template<typename T >
static const T & getAnyOf (const std::unordered_set< T > &container)
 
template<typename T >
static const T & getAnyOf (const boost::container::flat_set< T > &container)
 
template<typename T >
static const T & getAnyOf (const std::set< T > &container, const T &fallbackIfEmpty)
 Get any of std::set container. More...
 
template<typename T >
static const T & getAnyOf (const std::unordered_set< T > &container, const T &fallbackIfEmpty)
 
template<typename T >
static const T & getAnyOf (const boost::container::flat_set< T > &container, const T &fallbackIfEmpty)
 
template<typename T , typename S >
static const std::map< T, S >::const_iterator getAnyOf (const std::map< T, S > &container)
 Get any of std::map container. More...
 
template<typename T , typename S >
static const std::unordered_map< T, S >::const_iterator getAnyOf (const std::unordered_map< T, S > &container)
 
template<typename T , typename S >
static const boost::container::flat_map< T, S >::const_iterator getAnyOf (const boost::container::flat_map< T, S > &container)
 
template<typename T , typename S >
static const std::map< T, S >::const_iterator getAnyOf (const std::map< T, S > &container, const T &fallbackIfEmpty)
 Get any of std::map container. More...
 
template<typename T , typename S >
static const std::unordered_map< T, S >::const_iterator getAnyOf (const std::unordered_map< T, S > &container, const T &fallbackIfEmpty)
 
template<typename T , typename S >
static const boost::container::flat_map< T, S >::const_iterator getAnyOf (const boost::container::flat_map< T, S > &container, const T &fallbackIfEmpty)
 
template<typename T >
static T getPickOutAnyOf (std::vector< T > &container)
 Get any of std::vector container and erase the instance from the container. More...
 
template<typename T >
static T getPickOutAnyOf (std::set< T > &container)
 Get any of std::set container and erase the instance from the container. More...
 
template<typename T >
static T getPickOutAnyOf (std::unordered_set< T > &container)
 
template<typename T >
static T getPickOutAnyOf (boost::container::flat_set< T > &container)
 
template<typename T , typename S >
static T getPickOutAnyOf (std::map< T, S > &container)
 Get any of std::map container and erase the instance from the container. More...
 
template<typename T , typename S >
static T getPickOutAnyOf (std::unordered_map< T, S > &container)
 

Detailed Description

Static random number generation helper class.

Todo:
  • TODO(fw): This is just for ease-of-use of the QSF AI / Boost random number generation. It's not very efficient this way, and for the game, we might want to have better control over random number generation.

Definition at line 45 of file Random.h.

Member Function Documentation

template<typename RandomAccessIterator >
RandomAccessIterator qsf::Random::getAnyOf ( RandomAccessIterator  begin,
RandomAccessIterator  end 
)
static

Get any of container.

Note
  • Get any of will only work, if the container has random access iterators

Definition at line 26 of file Random-inl.h.

template<typename T >
const T & qsf::Random::getAnyOf ( const std::vector< T > &  container)
static

Get any of std::vector container.

Note
  • Throws an exception for an empty container, so check this first

Definition at line 39 of file Random-inl.h.

template<typename T >
const T & qsf::Random::getAnyOf ( const std::vector< T > &  container,
const T &  fallbackIfEmpty 
)
static

Get any of std::vector container.

Definition at line 48 of file Random-inl.h.

template<typename T >
const T & qsf::Random::getAnyOf ( const std::set< T > &  container)
static

Get any of std::set container.

Note
  • Throws an exception for an empty container, so check this first

Definition at line 58 of file Random-inl.h.

template<typename T >
const T & qsf::Random::getAnyOf ( const std::unordered_set< T > &  container)
static

Definition at line 71 of file Random-inl.h.

template<typename T >
const T & qsf::Random::getAnyOf ( const boost::container::flat_set< T > &  container)
static

Definition at line 84 of file Random-inl.h.

template<typename T >
const T & qsf::Random::getAnyOf ( const std::set< T > &  container,
const T &  fallbackIfEmpty 
)
static

Get any of std::set container.

Definition at line 97 of file Random-inl.h.

template<typename T >
const T & qsf::Random::getAnyOf ( const std::unordered_set< T > &  container,
const T &  fallbackIfEmpty 
)
static

Definition at line 111 of file Random-inl.h.

template<typename T >
const T & qsf::Random::getAnyOf ( const boost::container::flat_set< T > &  container,
const T &  fallbackIfEmpty 
)
static

Definition at line 125 of file Random-inl.h.

template<typename T , typename S >
static const std::map<T, S>::const_iterator qsf::Random::getAnyOf ( const std::map< T, S > &  container)
static

Get any of std::map container.

Note
  • Throws an exception for an empty container, so check this first
template<typename T , typename S >
static const std::unordered_map<T, S>::const_iterator qsf::Random::getAnyOf ( const std::unordered_map< T, S > &  container)
static
template<typename T , typename S >
const std::map<T, S>::const_iterator qsf::Random::getAnyOf ( const std::map< T, S > &  container)

Definition at line 139 of file Random-inl.h.

template<typename T , typename S >
static const boost::container::flat_map<T, S>::const_iterator qsf::Random::getAnyOf ( const boost::container::flat_map< T, S > &  container)
static
template<typename T , typename S >
static const std::map<T, S>::const_iterator qsf::Random::getAnyOf ( const std::map< T, S > &  container,
const T &  fallbackIfEmpty 
)
static

Get any of std::map container.

template<typename T , typename S >
static const std::unordered_map<T, S>::const_iterator qsf::Random::getAnyOf ( const std::unordered_map< T, S > &  container,
const T &  fallbackIfEmpty 
)
static
template<typename T , typename S >
static const boost::container::flat_map<T, S>::const_iterator qsf::Random::getAnyOf ( const boost::container::flat_map< T, S > &  container,
const T &  fallbackIfEmpty 
)
static
template<typename T , typename S >
const std::unordered_map<T, S>::const_iterator qsf::Random::getAnyOf ( const std::unordered_map< T, S > &  container)

Definition at line 152 of file Random-inl.h.

template<typename T , typename S >
const boost::container::flat_map<T, S>::const_iterator qsf::Random::getAnyOf ( const boost::container::flat_map< T, S > &  container)

Definition at line 165 of file Random-inl.h.

template<typename T , typename S >
const std::map<T, S>::const_iterator qsf::Random::getAnyOf ( const std::map< T, S > &  container,
const T &  fallbackIfEmpty 
)

Definition at line 178 of file Random-inl.h.

template<typename T , typename S >
const std::unordered_map<T, S>::const_iterator qsf::Random::getAnyOf ( const std::unordered_map< T, S > &  container,
const T &  fallbackIfEmpty 
)

Definition at line 192 of file Random-inl.h.

template<typename T , typename S >
const boost::container::flat_map<T, S>::const_iterator qsf::Random::getAnyOf ( const boost::container::flat_map< T, S > &  container,
const T &  fallbackIfEmpty 
)

Definition at line 206 of file Random-inl.h.

template<typename T >
T qsf::Random::getPickOutAnyOf ( std::vector< T > &  container)
static

Get any of std::vector container and erase the instance from the container.

Note
  • Throws an exception for an empty container, so check this first

Definition at line 220 of file Random-inl.h.

template<typename T >
T qsf::Random::getPickOutAnyOf ( std::set< T > &  container)
static

Get any of std::set container and erase the instance from the container.

Note
  • Throws an exception for an empty container, so check this first

Definition at line 233 of file Random-inl.h.

template<typename T >
T qsf::Random::getPickOutAnyOf ( std::unordered_set< T > &  container)
static

Definition at line 249 of file Random-inl.h.

template<typename T >
T qsf::Random::getPickOutAnyOf ( boost::container::flat_set< T > &  container)
static

Definition at line 265 of file Random-inl.h.

template<typename T , typename S >
T qsf::Random::getPickOutAnyOf ( std::map< T, S > &  container)
static

Get any of std::map container and erase the instance from the container.

Note
  • Throws an exception for an empty container, so check this first

Definition at line 281 of file Random-inl.h.

template<typename T , typename S >
T qsf::Random::getPickOutAnyOf ( std::unordered_map< T, S > &  container)
static

Definition at line 297 of file Random-inl.h.

bool qsf::Random::getRandomChance ( float  chance)
inlinestatic

Definition at line 20 of file Random-inl.h.

static float qsf::Random::getRandomFloat ( float  minimum,
float  maximum 
)
static

Returns a random floating point value in the range [min...max], that is including min and max as possible values.

static int32 qsf::Random::getRandomInt ( int32  minimum,
int32  maximum 
)
static

Returns a random signed integer in the range [min...max], that is including min and max as possible values.

static uint32 qsf::Random::getRandomUint ( uint32  minimum,
uint32  maximum 
)
static

Returns a random unsigned integer in the range [min...max], that is including min and max as possible values.


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