forpy
2
|
A lazy evaluation sampling without replacement. More...
#include <sampling.h>
Public Member Functions | |
SamplingWithoutReplacement (const T &min, const T &max, const std::shared_ptr< std::mt19937 > &random_engine) | |
bool | sample_available () const |
Returns true if a sample can be drawn without raising an exception. More... | |
T | get_next () |
Gets the next sample. More... | |
bool | operator== (const SamplingWithoutReplacement< T > &rhs) const |
Private Member Functions | |
SamplingWithoutReplacement () | |
template<class Archive > | |
void | serialize (Archive &ar, const uint &) |
Private Attributes | |
T | min |
std::shared_ptr< std::mt19937 > | random_engine |
std::uniform_int_distribution< T > | dist |
std::vector< T > | indices |
size_t | index |
Friends | |
class | cereal::access |
std::ostream & | operator<< (std::ostream &stream, const SamplingWithoutReplacement &self) |
A lazy evaluation sampling without replacement.
Returns a set of num unique numbers in range [min, max].
This needs to be stateful. Hence, it must store for each element whether it has been used yet. This renders it inefficient for use cases where only few instances need to be drawn.
min and max are both inclusive.
Definition at line 62 of file sampling.h.
|
inline |
Definition at line 64 of file sampling.h.
|
inlineprivate |
Definition at line 113 of file sampling.h.
|
inline |
Gets the next sample.
Definition at line 82 of file sampling.h.
|
inline |
Definition at line 107 of file sampling.h.
|
inline |
Returns true if a sample can be drawn without raising an exception.
Definition at line 77 of file sampling.h.
|
inlineprivate |
Definition at line 117 of file sampling.h.
|
friend |
Definition at line 113 of file sampling.h.
|
friend |
Definition at line 99 of file sampling.h.
|
private |
Definition at line 124 of file sampling.h.
|
private |
Definition at line 126 of file sampling.h.
|
private |
Definition at line 125 of file sampling.h.
|
private |
Definition at line 120 of file sampling.h.
|
private |
Definition at line 123 of file sampling.h.