RogueSharp
Show / Hide Table of Contents

Class KnownSeriesRandom

A class implementing IRandom which cycles through a specified series of integers each time the Next random number is asked for.

Inheritance
System.Object
KnownSeriesRandom
Implements
IRandom
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: RogueSharp.Random
Assembly: RogueSharp.dll
Syntax
public class KnownSeriesRandom : IRandom
Remarks

This class is normally used for unit tests and not production code.

Constructors

| Improve this Doc View Source

KnownSeriesRandom(Int32[])

Constructs a new integer generator with the specified series of integers in an array. When the Next method is called on this generator it will return the first integer in the series, followed by the next integer and so on until it reaches the end of the array. If the Next method is called once it is at the end of the array, it will start back over at the beginning.

Declaration
public KnownSeriesRandom(params int[] series)
Parameters
Type Name Description
System.Int32[] series

A known series of integers that will be returned in order from this generator

Exceptions
Type Condition
System.ArgumentNullException

Thrown on null series

Methods

| Improve this Doc View Source

Next(Int32)

Return the first integer in the series that was specified when this generator was constructed, followed by the next integer and so on until it reaches the end of the array. If the Next method is called once it is at the end of the array, it will start back over at the beginning.

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

Inclusive maximum result

Returns
Type Description
System.Int32

The next integer in the series specified upon construction of this class

Exceptions
Type Condition
System.ArgumentOutOfRangeException

Thrown when the Next integer in the series for this generator is not between 0 and the specified maxValue inclusive

| Improve this Doc View Source

Next(Int32, Int32)

Return the first integer in the series that was specified when this generator was constructed, followed by the next integer and so on until it reaches the end of the array. If the Next method is called once it is at the end of the array, it will start back over at the beginning.

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

Inclusive minimum result

System.Int32 maxValue

Inclusive maximum result

Returns
Type Description
System.Int32

The next integer in the series specified upon construction of this class

Exceptions
Type Condition
System.ArgumentOutOfRangeException

Thrown when the Next integer in the series for this generator is not between the specified minValue and maxValue inclusive

| Improve this Doc View Source

Restore(RandomState)

Restores the state of the number generator based on the specified state parameter

Declaration
public void Restore(RandomState state)
Parameters
Type Name Description
RandomState state

The state to restore to, usually obtained from calling the Save method

Examples

If you generated three random numbers and then called Save to store the state and followed that up by generating 10 more numbers before calling Restore with the previously saved RandomState the Restore method should return the generator back to the state when Save was first called. This means that if you went on to generate 10 more numbers they would be the same 10 numbers that were generated the first time after Save was called.

Exceptions
Type Condition
System.ArgumentNullException

Thrown on null RandomState

| Improve this Doc View Source

Save()

Saves the current state of the number generator

Declaration
public RandomState Save()
Returns
Type Description
RandomState

A RandomState class representing the current state of this number generator

Examples

If you generated three random numbers and then called Save to store the state and followed that up by generating 10 more numbers before calling Restore with the previously saved RandomState the Restore method should return the generator back to the state when Save was first called. This means that if you went on to generate 10 more numbers they would be the same 10 numbers that were generated the first time after Save was called.

Implements

IRandom
  • Improve this Doc
  • View Source
RogueSharp © 2014-2020 Faron Bracy
Back to top