vg
tools for working with variation graphs
Public Member Functions | Private Attributes | List of all members
vg::LazyRNG Class Reference

#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...
 

Detailed Description

AN RNG that can skip initialization and any hashing of the seed until it is needed. Not thread safe, not even a little bit.

Constructor & Destructor Documentation

◆ LazyRNG()

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.

Member Function Documentation

◆ operator()()

minstd_rand::result_type vg::LazyRNG::operator() ( )

Get a random number, computing the seed and initilaizing the RNG if that has not yet happened.

Member Data Documentation

◆ get_seed

std::function<string(void)> vg::LazyRNG::get_seed
private

Closure used to generate the seed. Makes sure to copy and not store a reference to a temporary closure.

◆ rng

unique_ptr<minstd_rand> vg::LazyRNG::rng
private

Backing RNG, or empty.


The documentation for this class was generated from the following files: