|
OpenEnroth 731eccc
|
#include <RandomEngine.h>
Public Member Functions | |
| virtual | ~RandomEngine ()=default |
| virtual float | randomFloat ()=0 |
| virtual int | random (int hi)=0 |
| virtual int | peek (int hi) const =0 |
| virtual void | seed (int seed)=0 |
| int | randomInSegment (int min, int max) |
| int | randomDice (int count, int faces) |
| bool | randomBool () |
| template<class Range , class T = typename Range::value_type> | |
| T | randomSample (const Range &range) |
| template<class T > | |
| T | randomSample (std::initializer_list< T > range) |
Random number generator interface.
Note that the methods of this class are NOT thread-safe, unlike their libc counterparts.
|
virtualdefault |
|
pure virtual |
Note that this method is mainly for debugging, implementation is not required to be efficient.
| hi | Upper bound for the result. Must be greater than zero. |
random(hi) will return. Implemented in TracingRandomEngine, MersenneTwisterRandomEngine, and SequentialRandomEngine.
|
pure virtual |
| hi | Upper bound for the result. Must be greater than zero. |
[0, hi). Implemented in TracingRandomEngine, MersenneTwisterRandomEngine, and SequentialRandomEngine.
|
inline |
| int RandomEngine::randomDice | ( | int | count, |
| int | faces | ||
| ) |
| count | Number of dice to throw. |
| faces | Number of faces on each die. |
|
pure virtual |
[0, 1). Implemented in TracingRandomEngine, MersenneTwisterRandomEngine, and SequentialRandomEngine.
| int RandomEngine::randomInSegment | ( | int | min, |
| int | max | ||
| ) |
| min | Minimal result value. |
| max | Maximal result value. Must be greater or equal to min. |
[min, max]. Note that both min and max are included in the interval.
|
inline |
| range | Random access range. |
|
inline |
|
pure virtual |
Reinitializes this random engine with the provided seed value. Passing 0 should be equivalent to calling an in-place destructor and then reconstructing the object.
| seed | Random seed. |
Implemented in TracingRandomEngine, MersenneTwisterRandomEngine, and SequentialRandomEngine.