rcolyer.net
RC Lib  Version 201607061602
Public Types | Public Member Functions | Static Public Member Functions | List of all members
RC::BaseRND Class Referenceabstract

An abstract class which provides functions for obtaining randomness in convenient forms. More...

#include <RND.h>

Inheritance diagram for RC::BaseRND:
RC::EntropyRND RC::RND RC::URand

Public Types

typedef u32 result_type
 For UniformRandomNumberGenerator compliance.
 

Public Member Functions

 BaseRND ()
 Default constructor.
 
virtual u32 Get_u32 ()=0
 Implement this for all subclasses. All other functions get their randomness from this. More...
 
u32 operator() ()
 Equivalent to Get_u32().
 
u32 min () const
 Returns 0 for UniformRandomNumberGenerator compliance.
 
u32 max () const
 Returns u32 max for UniformRandomNumberGenerator compliance.
 
i32 Get_i32 ()
 Provides random i32 values.
 
u64 Get_u64 ()
 Provides random u64 values.
 
i64 Get_i64 ()
 Provides random i64 values.
 
f32 Get_f32 ()
 Provides a random f32 in the range [0,1).
 
f64 Get_f64 ()
 Provides a random f64 in the range [0,1).
 
u8 Get_u8 ()
 Provides random u8 values.
 
i8 Get_i8 ()
 Provides random i8 values.
 
char Get_char ()
 Provides random char values.
 
u16 Get_u16 ()
 Provides random u16 values.
 
i16 Get_i16 ()
 Provides random i16 values.
 
void Get (u8 &x)
 Overloaded function to extract type u8 from this class. More...
 
void Get (i8 &x)
 Overloaded function to extract type i8 from this class. More...
 
void Get (char &x)
 Overloaded function to extract type char from this class. More...
 
void Get (u16 &x)
 Overloaded function to extract type u16 from this class. More...
 
void Get (i16 &x)
 Overloaded function to extract type i16 from this class. More...
 
void Get (u32 &x)
 Overloaded function to extract type u32 from this class. More...
 
void Get (i32 &x)
 Overloaded function to extract type i32 from this class. More...
 
void Get (u64 &x)
 Overloaded function to extract type u64 from this class. More...
 
void Get (i64 &x)
 Overloaded function to extract type i64 from this class. More...
 
void Get (f32 &x)
 Overloaded function to extract type f32 from this class. More...
 
void Get (f64 &x)
 Overloaded function to extract type f64 from this class. More...
 
bool GetProb (f64 probability)
 Returns true with probability, which should be in the range [0,1]. More...
 
bool GetProb (f32 probability)
 Returns true with probability, which should be in the range [0,1]. More...
 
u64 GetRange (u64 range)
 Returns [0,range) More...
 
i64 GetRange (i64 range)
 Like GetRange() but for i64.
 
u32 GetRange (u32 range)
 Like GetRange() but for i32. More...
 
i32 GetRange (i32 range)
 Like GetRange() but for i32.
 
template<class T >
GetRange (T low, T high)
 Provides a random integer value in the range [low,high].
 
f64 GetFRange (f64 low, f64 high)
 Provides a random float in the range [low,high).
 
template<class T >
void Fill (Data1D< T > &data)
 For any supported data type, fills the Data1D with random values.
 
template<class T >
GetFrom (Data1D< T > &data)
 Returns a random element from the Data1D.
 

Static Public Member Functions

static u64 GetEntropy ()
 Provides 64 bits of environmental entropy. More...
 

Detailed Description

An abstract class which provides functions for obtaining randomness in convenient forms.

It fulfills the UniformRandomNumberGenerator concept.

See also
RND
EntropyRND
URand

Member Function Documentation

void RC::BaseRND::Get ( u8 x)
inline

Overloaded function to extract type u8 from this class.

Parameters
xThe reference to which the value will be assigned.
void RC::BaseRND::Get ( i8 x)
inline

Overloaded function to extract type i8 from this class.

Parameters
xThe reference to which the value will be assigned.
void RC::BaseRND::Get ( char &  x)
inline

Overloaded function to extract type char from this class.

Parameters
xThe reference to which the value will be assigned.
void RC::BaseRND::Get ( u16 x)
inline

Overloaded function to extract type u16 from this class.

Parameters
xThe reference to which the value will be assigned.
void RC::BaseRND::Get ( i16 x)
inline

Overloaded function to extract type i16 from this class.

Parameters
xThe reference to which the value will be assigned.
void RC::BaseRND::Get ( u32 x)
inline

Overloaded function to extract type u32 from this class.

Parameters
xThe reference to which the value will be assigned.
void RC::BaseRND::Get ( i32 x)
inline

Overloaded function to extract type i32 from this class.

Parameters
xThe reference to which the value will be assigned.
void RC::BaseRND::Get ( u64 x)
inline

Overloaded function to extract type u64 from this class.

Parameters
xThe reference to which the value will be assigned.
void RC::BaseRND::Get ( i64 x)
inline

Overloaded function to extract type i64 from this class.

Parameters
xThe reference to which the value will be assigned.
void RC::BaseRND::Get ( f32 x)
inline

Overloaded function to extract type f32 from this class.

Parameters
xThe reference to which the value will be assigned.
void RC::BaseRND::Get ( f64 x)
inline

Overloaded function to extract type f64 from this class.

Parameters
xThe reference to which the value will be assigned.
virtual u32 RC::BaseRND::Get_u32 ( )
pure virtual

Implement this for all subclasses. All other functions get their randomness from this.

Returns
A random unsigned 32 bit integer.

Implemented in RC::URand, RC::EntropyRND, and RC::RND.

static u64 RC::BaseRND::GetEntropy ( )
inlinestatic

Provides 64 bits of environmental entropy.

This function uses the jittering of a tight loop relative to the ticking of the high precision clock to generate entropy, which is then mixed with the Rijndael S-box. It automatically adapts to the system's clock precision and relative cpu speed. The randomness has passed dieharder version 3.31.1.

Returns
64 bits of environmental entropy.
bool RC::BaseRND::GetProb ( f64  probability)
inline

Returns true with probability, which should be in the range [0,1].

Parameters
probabilityThe chance of returning true.
Returns
Randomly true according to probability.
bool RC::BaseRND::GetProb ( f32  probability)
inline

Returns true with probability, which should be in the range [0,1].

Parameters
probabilityThe chance of returning true.
Returns
Randomly true according to probability.
u64 RC::BaseRND::GetRange ( u64  range)
inline

Returns [0,range)

Note: The precision comes from f64, so it is slightly less than full u64 precision.

Parameters
rangeThe number of integers in the range.
Returns
A value from 0 up to range-1.
u32 RC::BaseRND::GetRange ( u32  range)
inline

Like GetRange() but for i32.

Note: The precision comes from f32, so it is slightly less than full u32 precision.


The documentation for this class was generated from the following file:
email address
— (c) 2015