Main Page | Class Hierarchy | Class List | File List | Class Members

RandomSequence Class Reference

#include <RandomSequence.h>

List of all members.

Public Member Functions

 RandomSequence (Randomizer &randomizer)
void setMode (bool predefined=false)
unsigned int seed () const
void setSeed (unsigned int seed)
int next (int limit)
 Generate a new random number, according to the current mode.


Detailed Description

Class implementing a random number sequence that can be re-played. Useful when attempting to create an exact copy of an object whose creation involved random numbers. The way it works is this: the first time, it generates random numbers using the given csp::Randomizer object. It stores the numbers returned, and after setMode(true) is called it will start returning those numbers through the next() method as if they were new numbers. After the last predefined random number is returned, the object will expect setMode() to be called again to establish the new mode of operation. See setMode()'s documentation for more details.


Constructor & Destructor Documentation

RandomSequence::RandomSequence Randomizer &  randomizer  ) 
 

Create a random sequence object ready to generate new random numbers.


Member Function Documentation

unsigned int RandomSequence::seed  )  const [inline]
 

The random number generator's seed set before creating this random sequence object.

void RandomSequence::setMode bool  predefined = false  ) 
 

Set the operating mode. If a transition from `new_numbers' to `predefined_numbers' is requested, the object will start returning random numbers from the list of random numbers it returned so far since it was last placed in `new' mode. A transition from `predefined_numbers' to `new_numbers' will clear the previous sequence. A non-transition request will simply clear the queue for `new_numbers' and start from the beginning for `predefined_numbers'.

Parameters:
predefined the mode of operation.

void RandomSequence::setSeed unsigned int  seed  )  [inline]
 

Set the random number generator's seed (the one to be set before creating this random sequence object).


The documentation for this class was generated from the following files:
Generated on Wed May 25 12:21:21 2005 for csp.kdevelop by  doxygen 1.3.9.1