ExtendedRandom.GetItemsWithoutReplacement Method

Definition

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

Overload List

GetItemsWithoutReplacement<T>(T[], Int32) Creates an array populated with items chosen at random from the provided set of choices without replacement.
GetItemsWithoutReplacement<T>(ReadOnlySpan<T>, Int32) Creates an array populated with items chosen at random from the provided set of choices without replacement.
GetItemsWithoutReplacement<T>(ReadOnlySpan<T>, Span<T>) Populates the specified span with items chosen at random from the provided set of choices without replacement.

GetItemsWithoutReplacement<T>(T[], Int32)

Creates an array populated with items chosen at random from the provided set of choices without replacement.
C#
public T[] GetItemsWithoutReplacement<T>(
	T[] choices,
	int length
)

Parameters

choices  T[]
The items to use to populate the array.
length  Int32
The length of the array to return.

Type Parameters

T
The type of the elements of choices.

Return Value

T[]
An array of length elements chosen from choices.

Exceptions

ArgumentNullException

choices is null.

ArgumentException

choices is empty.

ArgumentOutOfRangeException

length is less than zero.

GetItemsWithoutReplacement<T>(ReadOnlySpan<T>, Int32)

Creates an array populated with items chosen at random from the provided set of choices without replacement.
C#
public T[] GetItemsWithoutReplacement<T>(
	ReadOnlySpan<T> choices,
	int length
)

Parameters

choices  ReadOnlySpan<T>
The items to use to populate the array.
length  Int32
The length of the array to return.

Type Parameters

T
The type of the elements of choices.

Return Value

T[]
An array of length elements chosen from choices.

Exceptions

ArgumentException

choices is empty.

ArgumentOutOfRangeException

length is less than zero.

GetItemsWithoutReplacement<T>(ReadOnlySpan<T>, Span<T>)

Populates the specified span with items chosen at random from the provided set of choices without replacement.
C#
public void GetItemsWithoutReplacement<T>(
	ReadOnlySpan<T> choices,
	Span<T> destination
)

Parameters

choices  ReadOnlySpan<T>
The items to use to populate the span.
destination  Span<T>
The span to be filled with items.

Type Parameters

T
The type of the elements of choices.

Exceptions

ArgumentException

choices is empty.

See Also