vg
tools for working with variation graphs
|
#include <utility.hpp>
Public Member Functions | |
LazyRNG (const std::function< string(void)> &get_seed) | |
minstd_rand::result_type | operator() () |
Private Attributes | |
std::function< string(void)> | get_seed |
unique_ptr< minstd_rand > | rng |
Backing RNG, or empty. More... | |
AN RNG that can skip initialization and any hashing of the seed until it is needed. Not thread safe, not even a little bit.
vg::LazyRNG::LazyRNG | ( | const std::function< string(void)> & | get_seed | ) |
Make a new LazyRNG. Seed-generating closure will not be used after object is destroyed.
minstd_rand::result_type vg::LazyRNG::operator() | ( | ) |
Get a random number, computing the seed and initilaizing the RNG if that has not yet happened.
|
private |
Closure used to generate the seed. Makes sure to copy and not store a reference to a temporary closure.
|
private |
Backing RNG, or empty.