The OpenD Programming Language

VitterStrides

Random sampling utility. Complexity: O(n) References: Jeffrey Scott Vitter, An efficient algorithm for sequential random sampling

Constructors

this
this(size_t N, size_t n)

Postblit

A postblit is present on this object, but not explicitly documented in the source.

Members

Functions

empty
bool empty()
length
size_t length()
opCall
sizediff_t opCall(G gen)
tail
size_t tail()

Examples

import mir.random.engine.xorshift;
auto gen = Xorshift(112);
auto strides = VitterStrides(20, 3);
size_t s;
foreach(_; 0..3)
{
    s += strides(gen) + 1;
    assert(s + strides.tail == 20);
}

Meta