![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cRandom.h>
Public Types | |
typedef UINT | SEED_t |
default seed size might be 32 or 64 bit depending on k_RAND_MAX. More... | |
Public Member Functions | |
cRandomBase () noexcept | |
virtual | ~cRandomBase () |
virtual void | InitSeed (const void *pData, size_t iSize)=0 |
void | InitSeed (IRandomNoise *pSrc, size_t iSize) |
the default random number generator. NOT Thread Safe! More... | |
void | InitSeedDefault (size_t iSize=sizeof(int)) |
void | InitSeedUns (UINT iSeed) |
virtual HRESULT | GetNoise (void *pData, size_t iSize) override |
fill array with random. return # filled. More... | |
virtual UINT | get_RandUns () |
bool | GetRandBool () |
virtual UINT | GetRandUX (UINT nScale) |
int | GetRandIRange (int iRangeLo, int iRangeHi) |
Friends | |
class | cRandomTests |
Generic abstract base class for a integer/binary (pseudo) random number generator. Similar to .NET System.Random
typedef UINT Gray::cRandomBase::SEED_t |
default seed size might be 32 or 64 bit depending on k_RAND_MAX.
|
inlinenoexcept |
|
inlinevirtual |
|
virtual |
get UINT random number in 0 to < UINT_MAX range default implementation.
Reimplemented in GrayLib::cRandomWGenerator, GrayLib::cRandomBGenerator, GrayLib::cRandomMersenne, and Gray::cRandomOS.
|
overridevirtual |
fill array with random. return # filled.
fill a buffer with random bytes of data. < 0 = error.
Implements Gray::IRandomNoise.
Reimplemented in Gray::cRandomOS.
|
inline |
flip a coin.
int Gray::cRandomBase::GetRandIRange | ( | int | iRangeLo, |
int | iRangeHi | ||
) |
get a random integer inclusive inside range. default implementation.
|
virtual |
Get random number in scale. 0 to scale. unsigned integer is NON inclusive range. from 0 to nScale-1
get random integer number in 0 to < nScale range NON inclusive default implementation.
Reimplemented in GrayLib::cRandomFloatDef, GrayLib::cRandomCombo2< _TYPE1, _TYPE2 >, and Gray::cRandomDef.
|
pure virtual |
void Gray::cRandomBase::InitSeed | ( | IRandomNoise * | pSrc, |
size_t | iSize | ||
) |
the default random number generator. NOT Thread Safe!
void Gray::cRandomBase::InitSeedDefault | ( | size_t | iSize = sizeof(int) | ) |
Initialize random sequence randomly. Seed the random generator with time or some mix of more random data. NOT Deterministic!
void Gray::cRandomBase::InitSeedUns | ( | UINT | iSeed | ) |
set seed from UINT. Similar to SEED_t
|
friend |