/// ------------------------------------------------------
/// RandomOps - (Pseudo) Random Number Generator For C#
/// Copyright (C) 2003-2010 Magnus Erik Hvass Pedersen.
/// Please see the file license.txt for license details.
/// RandomOps on the internet: http://www.Hvass-Labs.org/
/// ------------------------------------------------------
using System;
namespace RandomOps
{
///
/// Pseudo-Random Number Generator (PRNG) base-class for a generator of UInt32 integers
/// that uses an array.
///
public abstract class RanUInt32Array : RanUInt32
{
#region Constructors.
///
/// Constructs the PRNG-object.
///
public RanUInt32Array()
: base()
{
}
///
/// Constructs the PRNG-object using the designated seed.
/// This is useful if you want to repeat experiments with the
/// same sequence of pseudo-random numbers.
///
public RanUInt32Array(UInt32[] seed)
: base()
{
Seed(seed);
}
///
/// Constructs the PRNG-object using another PRNG-object
/// for seeding.
///
public RanUInt32Array(Random rand)
: base()
{
Seed(rand);
}
#endregion
#region Seed.
///
/// Length of seed-array.
///
public abstract int SeedLength
{
get;
}
///
/// Seed with an array.
///
public abstract void Seed(UInt32[] seed);
///
/// Seed with random bytes from another RNG.
///
public void Seed(Random rand)
{
UInt32[] seed = new UInt32[SeedLength];
for (int i = 0; i < seed.Length; i++)
{
byte[] b = rand.Bytes(4);
seed[i] = BitConverter.ToUInt32(b, 0);
}
Seed(seed);
}
#endregion
#region Base-class overrides.
///
/// Seed with an integer.
///
protected sealed override void Seed()
{
throw new NotImplementedException();
}
///
/// Seed with an integer.
///
protected sealed override void Seed(UInt32 seed)
{
throw new NotImplementedException();
}
#endregion
}
}