C# Class RandomOps.Multi

Abstract class for using multiple RNGs that can be switched between. Example implementation is the Switcher-class which does the RNG-switching randomly. Thread-safe if supplied RNGs are thread-safe, and if SelectRand() is made thread-safe.
If you are using RNGs that have custom methods for generating random numbers then you need to extend this class in a fashion similar to that of the Uniform()-method.
Inheritance: Random
Exibir arquivo Open project: DanWBR/dwsim3

Public Methods

Method Description
Bool ( ) : bool

Draw a random boolean with equal probability of drawing true or false.

Byte ( ) : byte

Draw a random and uniform byte.

Bytes ( int length ) : byte[]

Draw an array of random and uniform bytes.

Multi ( Random rands )

Constructs the RNG-object from different RNG's.

Uniform ( ) : double

Draw a uniform random number in the exclusive range (0,1)

Protected Methods

Method Description
SelectRand ( ) : int

Select the RNG to use.

Private Methods

Method Description
Switch ( ) : void

Switch the RNG currently being used. This is to be called before every RNG-method call.

Method Details

Bool() public final method

Draw a random boolean with equal probability of drawing true or false.
public final Bool ( ) : bool
return bool

Byte() public final method

Draw a random and uniform byte.
public final Byte ( ) : byte
return byte

Bytes() public final method

Draw an array of random and uniform bytes.
public final Bytes ( int length ) : byte[]
length int The array length requested.
return byte[]

Multi() public method

Constructs the RNG-object from different RNG's.
public Multi ( Random rands )
rands Random The RNGs that will be switched between.

SelectRand() protected abstract method

Select the RNG to use.
protected abstract SelectRand ( ) : int
return int

Uniform() public final method

Draw a uniform random number in the exclusive range (0,1)
public final Uniform ( ) : double
return double