Extended Random.Get Items Without Replacement Method
Definition
Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
Overload List
Get | Creates an array populated with items chosen at random from the provided set of choices without replacement. |
Get | Creates an array populated with items chosen at random from the provided set of choices without replacement. |
Get | 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.
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
Argument | choices is null. |
Argument | choices is empty. |
Argument | 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.
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
Argument | choices is empty. |
Argument | 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.
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
Argument | choices is empty. |