/// ------------------------------------------------------
/// 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/
/// ------------------------------------------------------
namespace RandomOps
{
///
/// Randomly switch between different RNGs.
/// Thread-safe if RNGs are thread-safe.
///
///
/// This basically just implements the SelectRand() method
/// from the RandMulti-class.
///
public class Switcher : Multi
{
#region Constructor.
///
/// Constructs the RNG-object from other RNGs.
///
/// The RNG that will be used to determine switching.
/// The RNGs to switch between.
public Switcher(Random randSwitch, Random[] rands)
: base(rands)
{
RandSwitch = randSwitch;
}
#endregion
#region Internal variables.
///
/// The RNG used to determine when to switch.
///
Random RandSwitch;
#endregion
#region Base-class overrides.
///
/// Name of the RNG.
///
public override string Name
{
get { return "Switcher-" + base.Name; }
}
///
/// Determine which RNG in RandMulti to use.
///
/// Index for the RNG.
protected override int SelectRand()
{
return RandSwitch.Index(base.Rands.Length);
}
#endregion
}
}