Emergency 20 Dokumentation  4.1.0
Public Member Functions | Static Public Member Functions | List of all members
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 size_t getRandomSize (size_t minimum, size_t maximum)
 Returns a random size_t value 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.

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
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
template<typename T >
const T & qsf::Random::getAnyOf ( const std::vector< T > &  container,
const T &  fallbackIfEmpty 
)
static

Get any of std::vector container.

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
template<typename T >
const T & qsf::Random::getAnyOf ( const std::unordered_set< T > &  container)
static
template<typename T >
const T & qsf::Random::getAnyOf ( const boost::container::flat_set< T > &  container)
static
template<typename T >
const T & qsf::Random::getAnyOf ( const std::set< T > &  container,
const T &  fallbackIfEmpty 
)
static

Get any of std::set container.

template<typename T >
const T & qsf::Random::getAnyOf ( const std::unordered_set< T > &  container,
const T &  fallbackIfEmpty 
)
static
template<typename T >
const T & qsf::Random::getAnyOf ( const boost::container::flat_set< T > &  container,
const T &  fallbackIfEmpty 
)
static
template<typename T , typename S >
const std::map<T, S>::const_iterator qsf::Random::getAnyOf ( const std::map< T, S > &  container)
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 >
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 >
const std::unordered_map<T, S>::const_iterator qsf::Random::getAnyOf ( const std::unordered_map< T, S > &  container)
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 boost::container::flat_map<T, S>::const_iterator qsf::Random::getAnyOf ( const boost::container::flat_map< T, S > &  container)
template<typename T , typename S >
const std::map<T, S>::const_iterator qsf::Random::getAnyOf ( const std::map< T, S > &  container,
const T &  fallbackIfEmpty 
)
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 
)
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 
)
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
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
template<typename T >
T qsf::Random::getPickOutAnyOf ( std::unordered_set< T > &  container)
static
template<typename T >
T qsf::Random::getPickOutAnyOf ( boost::container::flat_set< T > &  container)
static
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
template<typename T , typename S >
T qsf::Random::getPickOutAnyOf ( std::unordered_map< T, S > &  container)
static
bool qsf::Random::getRandomChance ( float  chance)
inlinestatic
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 size_t qsf::Random::getRandomSize ( size_t  minimum,
size_t  maximum 
)
static

Returns a random size_t value 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: