Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
///Seed using an InputRange
void seedRange(T)(T range) if(isInputRange!T && is(Unqual!(ElementType!T) == UIntType))
{
int j;
for(j = 0; j < n && !range.empty; ++j, range.popFront())
{
mt[j] = range.front;
}
mti = n;
if(range.empty && j < n)
throw new Exception("MersenneTwisterEngine.seedRange: Input range didn't provide enough"
" elements");
popFront();
}
unittest
{
Mt19937 gen;
//This is repeating one unpredictableSeed! Not a good idea in general, but OK for the unittest
bool thrown = false;
try
gen.seedRange(repeat(unpredictableSeed, 623));
catch(Exception)
thrown = true;
assert(thrown);
gen.seedRange(repeat(unpredictableSeed, 624));
//infinite Range
gen.seedRange(repeat(unpredictableSeed));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.