A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4659/rand.adapt.shuf below:

[rand.adapt.shuf]

29 Numerics library [numerics] 29.6 Random number generation [rand] 29.6.4 Random number engine adaptor class templates [rand.adapt] 29.6.4.4 Class template shuffle_­order_­engine [rand.adapt.shuf]

A shuffle_­order_­engine random number engine adaptor produces the same random numbers that are produced by some base engine e, but delivers them in a different sequence. The state xi of a shuffle_­order_­engine engine adaptor object x consists of the state ei of its base engine e, an additional value Y of the type delivered by e, and an additional sequence V of k values also of the type delivered by e. The size of the state is the size of e's state plus k+1.

The transition algorithm permutes the values produced by e. The state transition is performed as follows:

  1. a)Calculate an integer j=k(Yemin)emaxemin+1 .

  2. b)Set Y to Vj and then set Vj to e().

The generation algorithm yields the last value of Y produced while advancing e's state as described above.

template<class Engine, size_t k>
  class shuffle_order_engine {
  public:
        using result_type = typename Engine::result_type;

        static constexpr size_t table_size = k;
    static constexpr result_type min() { return Engine::min(); }
    static constexpr result_type max() { return Engine::max(); }

        shuffle_order_engine();
    explicit shuffle_order_engine(const Engine& e);
    explicit shuffle_order_engine(Engine&& e);
    explicit shuffle_order_engine(result_type s);
    template<class Sseq> explicit shuffle_order_engine(Sseq& q);
    void seed();
    void seed(result_type s);
    template<class Sseq> void seed(Sseq& q);

        result_type operator()();
    void discard(unsigned long long z);

        const Engine& base() const noexcept { return e; };

  private:
    Engine e;               result_type V[k];       result_type Y;        };

The following relation shall hold: 0 < k.

The textual representation consists of the textual representation of e, followed by the k values of V, followed by the value of Y.

In addition to its behavior pursuant to section [rand.req.adapt], each constructor that is not a copy constructor initializes V[0],,V[k-1] and Y, in that order, with values returned by successive invocations of e().


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4