GLRandomNumbersGenerator Class Reference

#include <GLRandomNumbersGenerator.h>

List of all members.

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)


Detailed Description

Class to generate random numbers. By default uses standard stdlib rand() function. Can be initialised with particular seed or will do it using the timer value.

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.


Member Enumeration Documentation

Constants specific for use in random generator.

Definition at line 21 of file GLRandomNumbersGenerator.h.


Constructor & Destructor Documentation

virtual GLRandomNumbersGenerator::~GLRandomNumbersGenerator (  )  [inline, virtual]

Destructor. Actually does nothing.

Definition at line 29 of file GLRandomNumbersGenerator.h.


Member Function Documentation

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.

Parameters:
min minimal possible random value.
max maximal possible random value.
Returns:
random num: (num >= min) && (num < max)
Returns random number between 2 values.
Parameters:
min minimal possible random value.
max maximal possible random value.
Returns:
random num: (num >= left) && (num < right)

Definition at line 55 of file GLRandomNumbersGenerator.cpp.

long GLRandomNumbersGenerator::getRandomInteger ( const long &  max  )  [static]

Returns random number between 0 and max.

Parameters:
max maximal possible random value.
Returns:
random num: (num >= 0) && (num < max)

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.

Parameters:
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.
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.
Parameters:
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.

Returns:
seed which was used to start the random generator. If not initialised yet will return GLRandomNumbersGenerator::UNITIALISED_SEED.

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.

Parameters:
seed positive number to start the random generator or UNINITIALISED_SEED (default) to use timer.
Returns:
the integer which was actually used to start the generator.
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.
Parameters:
seed seed to start the random generator.
Returns:
the integer which was actually used to start the 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.

Returns:
the indicator if the random generator was initialised.

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.

Parameters:
result vector with the integer data (pevious content will be lost).
min minimal integer value.
max maximal integer value.
Returns the shuffled vector of integers between minimum and maximum values. The size of the resulting vector will be max-min.
Parameters:
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.


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

Generated on Sat Jun 13 13:58:11 2009 for GenLib by  doxygen 1.5.9