CellularAutomata
Loading...
Searching...
No Matches
CellularAutomata::random Namespace Reference

Global random number generator wrapping the std::random utilities. More...

Functions

void seed (unsigned int seed)
 Sets the given seed for the random number generator.
 
template<typename T >
std::enable_if< std::is_integral< T >::value, T >::type random (T min, T max)
 Returns a random number of given type on the range [min, max].
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, T >::type random (T min, T max)
 Returns a random number of given type on the range [min, max].
 

Detailed Description

Global random number generator wrapping the std::random utilities.

Attention
Since random works using static variables, each translation unit will have its own 'random' state
Note
The first seed used before calling 'seed()' is random

Function Documentation

◆ random() [1/2]

template<typename T >
std::enable_if< std::is_integral< T >::value, T >::type CellularAutomata::random::random ( min,
max 
)

Returns a random number of given type on the range [min, max].

Template Parameters
Ttype
Parameters
minminimal value
maxmaximal value
Returns
random value

◆ random() [2/2]

template<typename T >
std::enable_if< std::is_floating_point< T >::value, T >::type CellularAutomata::random::random ( min,
max 
)

Returns a random number of given type on the range [min, max].

Template Parameters
Ttype
Parameters
minminimal value
maxmaximal value
Returns
random value

◆ seed()

void CellularAutomata::random::seed ( unsigned int  seed)

Sets the given seed for the random number generator.

Parameters
seedseed to use