PersonalRandomNumberGenerator Class Reference
|
CPP API
|
Random number generator of individual persons. More...
#include <personal_rng.h>
Public Member Functions | |
| mio::Counter< uint64_t > | get_counter () const |
| mio::Key< uint64_t > | get_key () const |
| void | increment_counter () |
| Increment the counter. More... | |
| PersonalRandomNumberGenerator (mio::Key< uint64_t > key, uint32_t index, mio::Counter< uint32_t > &counter) | |
| Creates a RandomNumberGenerator for a person. More... | |
| PersonalRandomNumberGenerator (Person &person) | |
| Creates a RandomNumberGenerator for a person. More... | |
Private Attributes | |
| mio::Counter< uint32_t > & | m_counter |
| Reference to the Person's rng counter. More... | |
| mio::Key< uint64_t > | m_key |
| Global RNG Key. More... | |
| uint32_t | m_person_index |
| Index of the Person. More... | |
Detailed Description
Random number generator of individual persons.
Increments the random number generator counter of the person when used. Does not store its own key or counter. Instead the key needs to be provided from the outside, so that the RNG for all persons share the same key. The counter is taken from the person. PersonalRandomNumberGenerator is cheap to construct and transparent for the compiler to optimize, so we don't store the RNG persistently, only the counter, so we don't need to store the key in each person. This increases consistency (if the key is changed after the person is created) and reduces the memory required per person.
- See also
- mio::RandomNumberGeneratorBase
Constructor & Destructor Documentation
◆ PersonalRandomNumberGenerator() [1/2]
| mio::abm::PersonalRandomNumberGenerator::PersonalRandomNumberGenerator | ( | mio::Key< uint64_t > | key, |
| uint32_t | index, | ||
| mio::Counter< uint32_t > & | counter | ||
| ) |
◆ PersonalRandomNumberGenerator() [2/2]
| mio::abm::PersonalRandomNumberGenerator::PersonalRandomNumberGenerator | ( | Person & | person | ) |
Creates a RandomNumberGenerator for a person.
- Parameters
-
person Reference to the Person who's counter will be used.
Member Function Documentation
◆ get_counter()
|
inline |
- Returns
- Get the current counter.
◆ get_key()
|
inline |
- Returns
- Get the key.
◆ increment_counter()
|
inline |
Increment the counter.
Member Data Documentation
◆ m_counter
|
private |
Reference to the Person's rng counter.
◆ m_key
|
private |
Global RNG Key.
◆ m_person_index
Generated by