ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Common::RandomSource Class Reference

Simple random number generator. More...

#include <random.h>

List of all members.

Public Member Functions

 RandomSource (const String &name)
 Construct a new randomness source with the specific name.
void setSeed (uint32 seed)
uint32 getSeed () const
uint getRandomNumber (uint max)
 Generates a random unsigned integer in the interval [0, max].
uint getRandomBit ()
 Generates a random bit, i.e.
uint getRandomNumberRng (uint min, uint max)
 Generates a random unsigned integer in the interval [min, max].

Private Attributes

uint32 _randSeed

Detailed Description

Simple random number generator.

Although it is definitely not suitable for cryptographic purposes, it serves our purposes just fine.

Definition at line 36 of file random.h.


Constructor & Destructor Documentation

Common::RandomSource::RandomSource ( const String name  ) 

Construct a new randomness source with the specific name.

The name used name must be globally unique, and is used to register the randomness source with the active event recorder, if any.

Definition at line 30 of file random.cpp.


Member Function Documentation

uint Common::RandomSource::getRandomBit (  ) 

Generates a random bit, i.e.

either 0 or 1. Identical to getRandomNumber(1), but potentially faster.

Returns:
a random bit, either 0 or 1

Definition at line 52 of file random.cpp.

uint Common::RandomSource::getRandomNumber ( uint  max  ) 

Generates a random unsigned integer in the interval [0, max].

Parameters:
max the upper bound
Returns:
a random number in the interval [0, max]

Definition at line 46 of file random.cpp.

uint Common::RandomSource::getRandomNumberRng ( uint  min,
uint  max 
)

Generates a random unsigned integer in the interval [min, max].

Parameters:
min the lower bound
max the upper bound
Returns:
a random number in the interval [min, max]

Definition at line 58 of file random.cpp.

uint32 Common::RandomSource::getSeed (  )  const [inline]

Definition at line 51 of file random.h.

void Common::RandomSource::setSeed ( uint32  seed  ) 

Definition at line 42 of file random.cpp.


Member Data Documentation

Definition at line 38 of file random.h.


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


Generated on Sat Jan 12 2019 05:04:14 for ResidualVM by doxygen 1.7.1
curved edge   curved edge