An abstract class which provides functions for obtaining randomness in convenient forms. More...
#include <RND.h>
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(). | |
| 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 > | |
| 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 > | |
| T | GetFrom (Data1D< T > &data) |
| Returns a random element from the Data1D. | |
Static Public Member Functions | |
| constexpr static u32 | min () |
| Returns 0 for UniformRandomNumberGenerator compliance. | |
| constexpr static u32 | max () |
| Returns u32 max for UniformRandomNumberGenerator compliance. | |
| static u64 | GetEntropy () |
| Provides 64 bits of environmental entropy. More... | |
An abstract class which provides functions for obtaining randomness in convenient forms.
It fulfills the UniformRandomNumberGenerator concept.
|
inline |
Overloaded function to extract type char from this class.
| x | The reference to which the value will be assigned. |
|
inline |
Overloaded function to extract type f32 from this class.
| x | The reference to which the value will be assigned. |
|
inline |
Overloaded function to extract type f64 from this class.
| x | The reference to which the value will be assigned. |
|
inline |
Overloaded function to extract type i16 from this class.
| x | The reference to which the value will be assigned. |
|
inline |
Overloaded function to extract type i32 from this class.
| x | The reference to which the value will be assigned. |
|
inline |
Overloaded function to extract type i64 from this class.
| x | The reference to which the value will be assigned. |
|
inline |
Overloaded function to extract type i8 from this class.
| x | The reference to which the value will be assigned. |
|
inline |
Overloaded function to extract type u16 from this class.
| x | The reference to which the value will be assigned. |
|
inline |
Overloaded function to extract type u32 from this class.
| x | The reference to which the value will be assigned. |
|
inline |
Overloaded function to extract type u64 from this class.
| x | The reference to which the value will be assigned. |
|
inline |
Overloaded function to extract type u8 from this class.
| x | The reference to which the value will be assigned. |
|
pure virtual |
Implement this for all subclasses. All other functions get their randomness from this.
Implemented in RC::URand, RC::EntropyRND, and RC::RND.
|
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.
|
inline |
Returns true with probability, which should be in the range [0,1].
| probability | The chance of returning true. |
|
inline |
Returns true with probability, which should be in the range [0,1].
| probability | The chance of returning true. |
Like GetRange() but for i32.
Note: The precision comes from f32, so it is slightly less than full u32 precision.
Returns [0,range)
Note: The precision comes from f64, so it is slightly less than full u64 precision.
| range | The number of integers in the range. |
1.9.1