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 |
Constructor & Destructor Documentation
Construct the random generator.
- Parameters
-
type Type of the random generator. seed Initial seed. Since this value cannot be null, if so, seed is set to 1.
Member Function Documentation
|
protected |
Calculation function for Internal use.
|
protected |
Calculation function for Internal use.
|
protected |
Calculation function for Internal use.
void Reset | ( | const int | seed | ) |
Restart the sequence.
- Parameters
-
seed Initial 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
-
max Variable 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
-
arr Pointer to the array representing the vector. size Size of the vector.
Field Documentation
|
protected |
Type of the random generator.
|
protected |
Next random value.
|
protected |
Variable for Internal use.
|
protected |
Variable for Internal use.
|
protected |
Variable for Internal use.
|
protected |
Variable for Internal use.