The OpenD Programming Language

PhobosRandom

Extends a Mir-style random number generator to also be a Phobos-style uniform RNG. If Engine is already a Phobos-style uniform RNG, PhobosRandom is just an alias for Engine.

Constructors

this
this()

Default constructor and copy constructor are disabled.

this
this(A args)

Forward constructor arguments to Engine.

Postblit

this(this)
this(this)

Default constructor and copy constructor are disabled.

Members

Functions

opCall
Uint opCall()

Retain support for Mir-style random interface.

popFront
void popFront()
seed
void seed(A args)

Phobos-style random interface.

Properties

engine
inout(Engine) engine [@property getter]
front
Uint front [@property getter]
save
typeof(this) save [@property getter]
empty
enum bool empty;

Phobos-style random interface.

Variables

isRandomEngine
enum bool isRandomEngine;

Retain support for Mir-style random interface.

isUniformRandom
enum bool isUniformRandom;
max
enum Uint max;
min
enum Uint min;

Phobos-style random interface.

preferHighBits
enum bool preferHighBits;

Retain support for Mir-style random interface.

Examples

import mir.random.engine.xorshift: Xorshift1024StarPhi;
import std.random: isSeedable, isPhobosUniformRNG = isUniformRNG;
import std.range.primitives: isForwardRange;

alias RNG = PhobosRandom!Xorshift1024StarPhi;

//Phobos interface
static assert(isPhobosUniformRNG!(RNG, ulong));
static assert(isSeedable!(RNG, ulong));
static assert(isForwardRange!RNG);
//Mir interface
static assert(isSaturatedRandomEngine!RNG);
static assert(is(EngineReturnType!RNG == ulong));

auto gen = Xorshift1024StarPhi(1);
auto rng = RNG(1);
assert(gen() == rng.front);
rng.popFront();
assert(gen() == rng.front);
rng.popFront();
assert(gen() == rng());

gen.__ctor(1);
rng.seed(1);
assert(gen() == rng());

Meta