Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

Random Class Reference


Detailed Description

Utils for random numbers.

Definition at line 7 of file Random.h.

Static Public Member Functions

static void init ()
 Init random generator.
static int randomInt (int bound)
static double randomReal (double bound)
static unsigned char aByte (unsigned int index)
 Return a value from interval <0,255>.


Member Function Documentation

unsigned char Random::aByte unsigned int  index  )  [static]
 

Return a value from interval <0,255>.

Parameters:
index index of byte, the byte and a index is alway the same

Definition at line 54 of file Random.cpp.

00055 {
00056     return ms_randArray[index % ARRAY_SIZE];
00057 }

void Random::init  )  [static]
 

Init random generator.

Definition at line 20 of file Random.cpp.

00020              {
00021     srand( static_cast<unsigned>(time(NULL)) );
00022     for (int i = 0; i < ARRAY_SIZE; ++i) {
00023         ms_randArray[i] = randomInt(256);
00024     }
00025 }

int Random::randomInt int  bound  )  [static]
 

Definition at line 32 of file Random.cpp.

00033 {
00034     if (bound == 0) {
00035         return 0;
00036     }
00037     return rand() % bound;
00038 }

double Random::randomReal double  bound  )  [static]
 

Definition at line 44 of file Random.cpp.

00045 {
00046     return bound * rand() / (RAND_MAX + 1.0);
00047 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:56:23 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2