RandomSourceExtensions.Shuffle Method

Definition

Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0

Overload List

Shuffle<T>(IRandomSource, T[]) Shuffles the elements of an array in place using the Fisher-Yates algorithm.
Shuffle<T>(IRandomSource, IList<T>) Shuffles the elements of an IList<T> in place using the Fisher-Yates algorithm.
Shuffle<T>(IRandomSource, Span<T>) Shuffles the elements of a span in place using the Fisher-Yates algorithm.
Shuffle<TGenerator, T>(IRandomSource<TGenerator>, T[]) Shuffles the elements of an array in place using the Fisher-Yates algorithm.
Shuffle<TGenerator, T>(IRandomSource<TGenerator>, Span<T>) Shuffles the elements of a span in place using the Fisher-Yates algorithm.

Shuffle<T>(IRandomSource, T[])

Shuffles the elements of an array in place using the Fisher-Yates algorithm.
C#
public static void Shuffle<T>(
	this IRandomSource rng,
	T[] array
)

Parameters

rng  IRandomSource
 
array  T[]
The array to shuffle.

Type Parameters

T
The type of elements in the array.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IRandomSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Shuffle<T>(IRandomSource, IList<T>)

Shuffles the elements of an IList<T> in place using the Fisher-Yates algorithm.
C#
public static void Shuffle<T>(
	this IRandomSource rng,
	IList<T> list
)

Parameters

rng  IRandomSource
 
list  IList<T>
The list to shuffle.

Type Parameters

T
The type of elements in the list.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IRandomSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Shuffle<T>(IRandomSource, Span<T>)

Shuffles the elements of a span in place using the Fisher-Yates algorithm.
C#
public static void Shuffle<T>(
	this IRandomSource rng,
	Span<T> span
)

Parameters

rng  IRandomSource
 
span  Span<T>
The span to shuffle.

Type Parameters

T
The type of elements in the span.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IRandomSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Shuffle<TGenerator, T>(IRandomSource<TGenerator>, T[])

Shuffles the elements of an array in place using the Fisher-Yates algorithm.
C#
public static void Shuffle<TGenerator, T>(
	this IRandomSource<TGenerator> rng,
	T[] array
)
where TGenerator : struct, new(), IRandomGenerator

Parameters

rng  IRandomSource<TGenerator>
 
array  T[]
The array to shuffle.

Type Parameters

TGenerator
T
The type of elements in the array.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IRandomSource<TGenerator>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Shuffle<TGenerator, T>(IRandomSource<TGenerator>, Span<T>)

Shuffles the elements of a span in place using the Fisher-Yates algorithm.
C#
public static void Shuffle<TGenerator, T>(
	this IRandomSource<TGenerator> rng,
	Span<T> span
)
where TGenerator : struct, new(), IRandomGenerator

Parameters

rng  IRandomSource<TGenerator>
 
span  Span<T>
The span to shuffle.

Type Parameters

TGenerator
T
The type of elements in the span.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IRandomSource<TGenerator>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also