Table of Contents

Class Xoshiro256PlusPlus

Namespace
BelNytheraSeiche.TrieDictionary
Assembly
BelNytheraSeiche.TrieDictionary.dll

Represents a 64-bit pseudo-random number generator based on the xoshiro256++ algorithm.

public class Xoshiro256PlusPlus : ICloneable
Inheritance
Xoshiro256PlusPlus
Implements
Inherited Members

Remarks

This generator is not cryptographically secure.

Constructors

Xoshiro256PlusPlus()

Initializes a new instance of the Xoshiro256PlusPlus class, using a unique seed value derived from a new GUID.

public Xoshiro256PlusPlus()

Xoshiro256PlusPlus(Xoshiro256PlusPlus)

Initializes a new instance of the Xoshiro256PlusPlus class by copying the state from another instance.

public Xoshiro256PlusPlus(Xoshiro256PlusPlus obj)

Parameters

obj Xoshiro256PlusPlus

The Xoshiro256PlusPlus instance to copy the state from.

Remarks

This constructor is primarily intended for replicating the state of the generator for parallel processing scenarios. After creating a copy, call the Jump() method on one of the instances to ensure that each generator produces a non-overlapping sequence of random numbers.

Exceptions

ArgumentNullException

obj is null.

Xoshiro256PlusPlus(ulong)

Initializes a new instance of the Xoshiro256PlusPlus class, using the specified seed value.

public Xoshiro256PlusPlus(ulong seed)

Parameters

seed ulong

A number used to calculate a starting value for the pseudo-random number sequence.

Methods

Clone()

Creates a new object that is a shallow copy of the current instance.

public object Clone()

Returns

object

A new object that is a shallow copy of this instance.

Remarks

This constructor is primarily intended for replicating the state of the generator for parallel processing scenarios. After creating a copy, call the Jump() method on one of the instances to ensure that each generator produces a non-overlapping sequence of random numbers.

Jump()

Advances the state of the generator by 4^64 steps.

public void Jump()

Remarks

This is equivalent to generating 4^64 random numbers and discarding them, but it is executed much faster. It is useful for creating non-overlapping subsequences for parallel random number generation.

Next()

Returns a non-negative random integer.

public int Next()

Returns

int

A 32-bit signed integer that is greater than or equal to 0 and less than MaxValue.

Next(int)

Returns a non-negative random integer that is less than the specified maximum.

public int Next(int maxValue)

Parameters

maxValue int

The exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to 0.

Returns

int

A 32-bit signed integer that is greater than or equal to 0, and less than maxValue.

Remarks

If maxValue is 0, this method will always return 0.

Next(int, int)

Returns a random integer that is within a specified range.

public int Next(int minValue, int maxValue)

Parameters

minValue int

The inclusive lower bound of the random number returned.

maxValue int

The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue.

Returns

int

A 32-bit signed integer greater than or equal to minValue and less than maxValue.

Remarks

If minValue equals maxValue, this method returns minValue.

Exceptions

ArgumentOutOfRangeException

minValue is greater than maxValue.

NextBytes(Span<byte>)

Fills the elements of a specified span of bytes with random numbers.

public void NextBytes(Span<byte> buffer)

Parameters

buffer Span<byte>

The span of bytes to fill with random numbers.

NextDouble()

Returns a random double-precision floating-point number that is greater than or equal to 0.0, and less than 1.0.

public double NextDouble()

Returns

double

A double-precision floating-point number that is greater than or equal to 0.0 and less than 1.0.

NextInt64()

Returns a non-negative random 64-bit integer.

public long NextInt64()

Returns

long

A 64-bit signed integer that is greater than or equal to 0 and less than MaxValue.

NextInt64(int)

Returns a non-negative random 64-bit integer that is less than the specified maximum.

public long NextInt64(int maxValue)

Parameters

maxValue int

The exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to 0.

Returns

long

A 64-bit signed integer that is greater than or equal to 0, and less than maxValue.

Remarks

If maxValue is 0, this method will always return 0.

NextInt64(long, long)

Returns a random 64-bit integer that is within a specified range.

public long NextInt64(long minValue, long maxValue)

Parameters

minValue long

The inclusive lower bound of the random number returned.

maxValue long

The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue.

Returns

long

A 64-bit signed integer greater than or equal to minValue and less than maxValue.

Remarks

If minValue equals maxValue, this method returns minValue.

Exceptions

ArgumentOutOfRangeException

minValue is greater than maxValue.

NextSingle()

Returns a random single-precision floating-point number that is greater than or equal to 0.0, and less than 1.0.

public float NextSingle()

Returns

float

A single-precision floating-point number that is greater than or equal to 0.0f and less than 1.0f.

Shuffle<T>(IList<T>)

Randomizes the order of the elements in a list.

public void Shuffle<T>(IList<T> values)

Parameters

values IList<T>

The list whose elements to shuffle.

Type Parameters

T

The type of the elements of the list.

Remarks

This method uses the Fisher-Yates shuffle algorithm.

Exceptions

ArgumentNullException

values is null.

Shuffle<T>(Span<T>)

Randomizes the order of the elements in a span.

public void Shuffle<T>(Span<T> values)

Parameters

values Span<T>

The span whose elements to shuffle.

Type Parameters

T

The type of the elements of the span.

Remarks

This method uses the Fisher-Yates shuffle algorithm.