Home | Libraries | People | FAQ | More |
boost::random::discard_block_engine
// In header: <boost/random/discard_block.hpp> template<typename UniformRandomNumberGenerator, std::size_t p, std::size_t r> class discard_block_engine { public: // types typedef UniformRandomNumberGenerator base_type; typedef base_type::result_type result_type; // construct/copy/destruct discard_block_engine(); explicit discard_block_engine(const base_type &); explicit discard_block_engine(base_type &&); explicit discard_block_engine(seed_type); template<typename SeedSeq> explicit discard_block_engine(SeedSeq &); template<typename It> discard_block_engine(It &, It); // public member functions void seed(); void seed(seed_type); template<typename SeedSeq> void seed(SeedSeq &); template<typename It> void seed(It &, It); const base_type & base() const; result_type operator()(); void discard(boost::uintmax_t); template<typename It> void generate(It, It); // public static functions static result_type min(); static result_type max(); // friend functions template<typename CharT, typename Traits> friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &, const discard_block_engine &); template<typename CharT, typename Traits> friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &, discard_block_engine &); friend bool operator==(const discard_block_engine &, const discard_block_engine &); friend bool operator!=(const discard_block_engine &, const discard_block_engine &); // public data members static const std::size_t block_size; static const std::size_t used_block; static const bool has_fixed_range; static const std::size_t total_block; static const std::size_t returned_block; };
The class template discard_block_engine is a model of pseudo-random number generator . It modifies another generator by discarding parts of its output. Out of every block of p
results, the first r
will be returned and the rest discarded.
Requires: 0 < p <= r
discard_block_engine
public
construct/copy/destructdiscard_block_engine();
Uses the default seed for the base generator.
explicit discard_block_engine(const base_type & rng);
Constructs a new discard_block_engine
with a copy of rng.
explicit discard_block_engine(base_type && rng);
Constructs a new discard_block_engine
with rng.
explicit discard_block_engine(seed_type value);
Creates a new discard_block_engine
and seeds the underlying generator with value
template<typename SeedSeq> explicit discard_block_engine(SeedSeq & seq);
Creates a new discard_block_engine
and seeds the underlying generator with seq
template<typename It> discard_block_engine(It & first, It last);
Creates a new discard_block_engine
and seeds the underlying generator with first and last.
discard_block_engine
public member functionsvoid seed();
default seeds the underlying generator.
void seed(seed_type s);
Seeds the underlying generator with s.
template<typename SeedSeq> void seed(SeedSeq & seq);
Seeds the underlying generator with seq.
template<typename It> void seed(It & first, It last);
Seeds the underlying generator with first and last.
const base_type & base() const;
Returns the underlying engine.
result_type operator()();
Returns the next value of the generator.
void discard(boost::uintmax_t z);
template<typename It> void generate(It first, It last);
discard_block_engine
friend functionstemplate<typename CharT, typename Traits> friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > & os, const discard_block_engine & s);
Writes a discard_block_engine
to a std::ostream
.
template<typename CharT, typename Traits> friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > & is, discard_block_engine & s);
Reads a discard_block_engine
from a std::istream
.
friend bool operator==(const discard_block_engine & x, const discard_block_engine & y);
Returns true if the two generators will produce identical sequences.
friend bool operator!=(const discard_block_engine & x, const discard_block_engine & y);
Returns true if the two generators will produce different sequences.