#include <GLRandomNumbersGenerator.h>
Public Types | |
enum | GeneratorConstants { UNINITIALISED_SEED = -1 } |
Public Member Functions | |
virtual | ~GLRandomNumbersGenerator () |
Static Public Member Functions | |
static long | getMaxNumber () |
static long | getRandomInteger () |
static long | getRandomInteger (const long &max) |
static long | getRandomInteger (const long &min, const long &max) |
static double | getRandomUniform (const double &left, const double &right) |
static long | getSeed () |
static long | initGenerator (long seed=UNINITIALISED_SEED) |
static int | isInitialised () |
static void | shuffleIntegerVector (vector< int > &result, const long &min, const long &max) |
Each time when generator initialised with the same seed it will produce the same sequence of random integer numbers.
Definition at line 15 of file GLRandomNumbersGenerator.h.
Constants specific for use in random generator.
Definition at line 21 of file GLRandomNumbersGenerator.h.
virtual GLRandomNumbersGenerator::~GLRandomNumbersGenerator | ( | ) | [inline, virtual] |
Destructor. Actually does nothing.
Definition at line 29 of file GLRandomNumbersGenerator.h.
static long GLRandomNumbersGenerator::getMaxNumber | ( | ) | [inline, static] |
Returns the maximum integer number which can be randomly generated.
Definition at line 34 of file GLRandomNumbersGenerator.h.
long GLRandomNumbersGenerator::getRandomInteger | ( | const long & | min, | |
const long & | max | |||
) | [static] |
Returns random number between 2 values.
min | minimal possible random value. | |
max | maximal possible random value. |
min | minimal possible random value. | |
max | maximal possible random value. |
Definition at line 55 of file GLRandomNumbersGenerator.cpp.
long GLRandomNumbersGenerator::getRandomInteger | ( | const long & | max | ) | [static] |
Returns random number between 0 and max.
max | maximal possible random value. |
Definition at line 25 of file GLRandomNumbersGenerator.cpp.
long GLRandomNumbersGenerator::getRandomInteger | ( | ) | [static] |
Generates the random integer number. If random generator was not initialised -- initialised it with timer value.
Definition at line 14 of file GLRandomNumbersGenerator.cpp.
double GLRandomNumbersGenerator::getRandomUniform | ( | const double & | min, | |
const double & | max | |||
) | [static] |
Creates the vector of random integer numbers within the given limits. If flag mayRepeat is set to false then elements of vector will be unique (not repeating). Note, that in this case max - min should be >= size, otherwise there are not enough elements to fill the vector. Note, that previous contain of the vector will be lost.
result | resulting vector of random integer. | |
min | minimum possible value for integer. | |
max | maximum possible value for integer. | |
size | size of the vector (number of random integers to be generated). | |
mayRepeat | when true false elements of results vector should be unique. Returns uniformly distributed double from the given range. | |
left | minimal possible random value. | |
right | maximal possible random value. |
result | resulting vector of random integer. | |
min | minimum possible value for integer. | |
max | maximum possible value for integer. | |
size | size of the vector (number of random integers to be generated). | |
mayRepeat | when true false elements of results vector should be unique. Returns uniformly distributed double from the given range. | |
min | minimal possible random value. | |
max | maximal possible random value. |
Definition at line 126 of file GLRandomNumbersGenerator.cpp.
static long GLRandomNumbersGenerator::getSeed | ( | ) | [inline, static] |
Returns seed which was used to run the random generator.
Definition at line 91 of file GLRandomNumbersGenerator.h.
long GLRandomNumbersGenerator::initGenerator | ( | long | seed = UNINITIALISED_SEED |
) | [static] |
Initialised random generator with given positive value or (if UNITIALISED_SEED was passed) with the timer. Returns the value which was used to initialised generator. Note, that if the same value was used to start generator it will produce the same sequence of random values.
seed | positive number to start the random generator or UNINITIALISED_SEED (default) to use timer. |
seed | seed to start the random generator. |
Definition at line 153 of file GLRandomNumbersGenerator.cpp.
static int GLRandomNumbersGenerator::isInitialised | ( | ) | [inline, static] |
Returns true if the generator was initialised with the seed and false otherwise.
Definition at line 110 of file GLRandomNumbersGenerator.h.
void GLRandomNumbersGenerator::shuffleIntegerVector | ( | vector< int > & | result, | |
const long & | min, | |||
const long & | max | |||
) | [static] |
Returns the shuffled vector of integers between minimum and maximum values. The size of the resulting vector will be max-min.
result | vector with the integer data (pevious content will be lost). | |
min | minimal integer value. | |
max | maximal integer value. |
result | vector with the ineger data (pevious content will be lost). | |
minimal | integer value (included). | |
maximal | integer value (not included). |
Definition at line 172 of file GLRandomNumbersGenerator.cpp.