Random Generator. More...

#include <rrandom.h>

Public Types

enum  tRandom { Good, Better, Best }
 

Public Member Functions

 RRandom (tRandom type, const int seed=1)
 
void Reset (const int seed)
 
double GetValue (void)
 
long GetValue (const long max)
 
int GetSeed (void) const
 
template<class T >
void RandOrder (T *arr, size_t size)
 

Protected Member Functions

int Calc1 (void)
 
int Calc2 (void)
 
int Calc3 (void)
 

Protected Attributes

tRandom Type
 
int Seed
 
int Aux1
 
int Aux2
 
int Table [32]
 
int Value
 

Detailed Description

Random Generator.

This is a class representing a random generator. In practice, it is an abstract class internally re-implemented.

Member Enumeration Documentation

enum tRandom

Type of the random generator.

Enumerator
Good 
Better 
Best 

Constructor & Destructor Documentation

RRandom ( tRandom  type,
const int  seed = 1 
)

Construct the random generator.

Parameters
typeType of the random generator.
seedInitial seed. Since this value cannot be null, if so, seed is set to 1.

Member Function Documentation

int Calc1 ( void  )
protected

Calculation function for Internal use.

int Calc2 ( void  )
protected

Calculation function for Internal use.

int Calc3 ( void  )
protected

Calculation function for Internal use.

void Reset ( const int  seed)

Restart the sequence.

Parameters
seedInitial seed. Since this value cannot be null, if so, seed is set to 1.
double GetValue ( void  )

Get the next value in the sequence.

Returns
a value in [0,1].
long GetValue ( const long  max)

Get the next value in the sequence as an integer.

Parameters
maxVariable used to calculate the number.
Returns
a number in the interval [0,max[.
int GetSeed ( void  ) const

Return the seed value.

void RandOrder ( T *  arr,
size_t  size 
)

Randomize the position of elements of a vector.

Parameters
arrPointer to the array representing the vector.
sizeSize of the vector.

Field Documentation

tRandom Type
protected

Type of the random generator.

int Seed
protected

Next random value.

int Aux1
protected

Variable for Internal use.

int Aux2
protected

Variable for Internal use.

int Table[32]
protected

Variable for Internal use.

int Value
protected

Variable for Internal use.