Show / Hide Table of Contents

Class KnownSeriesGenerator

"Random number generator" that takes in a series of values, and simply returns them sequentially when RNG functions are called.

Inheritance
System.Object
KnownSeriesGenerator
Implements
Troschuetz.Random.IGenerator
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: GoRogue.Random
Assembly: GoRogue.dll
Syntax
public class KnownSeriesGenerator : IGenerator
Remarks

This class may be useful for testing, when you want to specify the numbers returned by an RNG without drastically modifying any code using the RNG.

Constructors

| Improve this Doc View Source

KnownSeriesGenerator(IEnumerable<Int32>, IEnumerable<UInt32>, IEnumerable<Double>, IEnumerable<Boolean>, IEnumerable<Byte>)

Creates a new known series generator, with parameters to indicate which series to use for the integer, unsigned integer, double, bool, and byte-based RNG functions. If null is specified, no values of that type may be returned, and functions that try to return a value of that type will throw an exception.

Declaration
public KnownSeriesGenerator(IEnumerable<int> intSeries = null, IEnumerable<uint> uintSeries = null, IEnumerable<double> doubleSeries = null, IEnumerable<bool> boolSeries = null, IEnumerable<byte> byteSeries = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Int32> intSeries
System.Collections.Generic.IEnumerable<System.UInt32> uintSeries
System.Collections.Generic.IEnumerable<System.Double> doubleSeries
System.Collections.Generic.IEnumerable<System.Boolean> boolSeries
System.Collections.Generic.IEnumerable<System.Byte> byteSeries

Properties

| Improve this Doc View Source

CanReset

Whether or not the RNG is capable of resetting, such that it will return the same series of values again.

Declaration
public bool CanReset { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Seed

Since this RNG returns a known series of values, this field will always return 0.

Declaration
public uint Seed { get; }
Property Value
Type Description
System.UInt32

Methods

| Improve this Doc View Source

Next()

Gets the next integer in the underlying series. If the integer is equal to System.Int32.MaxValue, throws an exception.

Declaration
public int Next()
Returns
Type Description
System.Int32

The next integer in the underlying series.

| Improve this Doc View Source

Next(Int32)

Gets the next number in the underlying int series. If the value is less than 0 or greater than/equal to maxValue, throws an exception.

Declaration
public int Next(int maxValue)
Parameters
Type Name Description
System.Int32 maxValue

Maximum allowable number that can be returned (exclusive).

Returns
Type Description
System.Int32

The appropriate number from the series.

| Improve this Doc View Source

Next(Int32, Int32)

Gets the next number in the underlying series. If the value is less than minValue or greater than/equal to maxValue, throws an exception.

Declaration
public int Next(int minValue, int maxValue)
Parameters
Type Name Description
System.Int32 minValue

Minimum allowable number that can be returned.

System.Int32 maxValue

Maximum allowable number that can be returned (exclusive).

Returns
Type Description
System.Int32

The appropriate number from the series.

| Improve this Doc View Source

NextBoolean()

Returns the next boolean in the underlying series.

Declaration
public bool NextBoolean()
Returns
Type Description
System.Boolean

The next boolean value in the underlying series.

| Improve this Doc View Source

NextBytes(Byte[])

Fills the specified buffer with values from the underlying byte series.

Declaration
public void NextBytes(byte[] buffer)
Parameters
Type Name Description
System.Byte[] buffer

Buffer to fill.

| Improve this Doc View Source

NextDouble()

Returns the next double in the underlying series. If the double is less than 0.0 or greater than/equal to 1.0, throws an exception.

Declaration
public double NextDouble()
Returns
Type Description
System.Double

The next double in the underlying series.

| Improve this Doc View Source

NextDouble(Double)

Returns the next double in the underlying series. If the double is less than 0.0 or greater than/equal to maxValue, throws an exception.

Declaration
public double NextDouble(double maxValue)
Parameters
Type Name Description
System.Double maxValue

The maximum value for the returned value, exclusive.

Returns
Type Description
System.Double

The next double in the underlying series.

| Improve this Doc View Source

NextDouble(Double, Double)

Returns the next double in the underlying series. If the double is less than minValue or greater than/equal to maxValue, throws an exception.

Declaration
public double NextDouble(double minValue, double maxValue)
Parameters
Type Name Description
System.Double minValue

Minimum value for the returned number, inclusive.

System.Double maxValue

Maximum value for the returned number, exclusive.

Returns
Type Description
System.Double

The next double in the underlying series.

| Improve this Doc View Source

NextInclusiveMaxValue()

Returns the next integer in the underlying series. If the value is less than 0, throws an exception.

Declaration
public int NextInclusiveMaxValue()
Returns
Type Description
System.Int32

The next integer in the underlying series.

| Improve this Doc View Source

NextUInt()

Returns the next unsigned integer in the underlying series. If the value is equal to System.UInt32.MaxValue, throws an exception.

Declaration
public uint NextUInt()
Returns
Type Description
System.UInt32

The next unsigned integer in the underlying series.

| Improve this Doc View Source

NextUInt(UInt32)

Returns the next unsigned integer in the underlying series. If the value is greater than or equal to maxValue, throws an exception.

Declaration
public uint NextUInt(uint maxValue)
Parameters
Type Name Description
System.UInt32 maxValue

The maximum value for the returned number, exclusive.

Returns
Type Description
System.UInt32

The next unsigned integer in the underlying series.

| Improve this Doc View Source

NextUInt(UInt32, UInt32)

Returns the next unsigned integer in the underlying series. If the value is less than minValue, or greater than/equal to maxValue, throws an exception.

Declaration
public uint NextUInt(uint minValue, uint maxValue)
Parameters
Type Name Description
System.UInt32 minValue

The minimum value for the returned number, inclusive.

System.UInt32 maxValue

The maximum value for the returned number, exclusive.

Returns
Type Description
System.UInt32

The next unsigned integer in the underlying series.

| Improve this Doc View Source

NextUIntExclusiveMaxValue()

Returns the next unsigned integer in the underlying series. If the value is equal to System.UInt32.MaxValue, throws an exception.

Declaration
public uint NextUIntExclusiveMaxValue()
Returns
Type Description
System.UInt32

The next unsigned integer in the underlying series.

| Improve this Doc View Source

NextUIntInclusiveMaxValue()

Returns the next unsigned integer in the underlying series.

Declaration
public uint NextUIntInclusiveMaxValue()
Returns
Type Description
System.UInt32

The next unsinged integer in the underlying series.

| Improve this Doc View Source

Reset()

Resets the random number generator, such that it starts returning values from the beginning of the underlying series.

Declaration
public bool Reset()
Returns
Type Description
System.Boolean

True, since the reset cannot fail.

| Improve this Doc View Source

Reset(UInt32)

Resets the random number generator, such that it starts returning the values from the beginning of the underlying series.

Declaration
public bool Reset(uint seed)
Parameters
Type Name Description
System.UInt32 seed

Unused, since there is no seed for a known-series RNG.

Returns
Type Description
System.Boolean

True, since the reset cannot fail.

Implements

Troschuetz.Random.IGenerator

Extension Methods

Utility.Yield<T>(T)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX