Shuffle Method
Definition
- Namespace
- Cuemon.Extensions.Collections.Generic
- Assemblies
- Cuemon.Extensions.Collections.Generic.dll
Shuffle<T>(IEnumerable<T>)
Shuffles the specified source like a deck of cards.
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source)
Parameters
sourceIEnumerable<T>An IEnumerable<T> to extend.
Returns
- IEnumerable<T>
A sequence of
Twith the shuffledsource.
Type Parameters
T
Remarks
Fisher–Yates shuffle: https://en.wikipedia.org/wiki/Fisher–Yates_shuffle
Shuffle<T>(IEnumerable<T>, Func<int, int, int>)
Shuffles the specified source like a deck of cards.
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source, Func<int, int, int> randomizer)
Parameters
sourceIEnumerable<T>An IEnumerable<T> to extend.
randomizerFunc<int, int, int>The function delegate that will handle the randomization of
source.
Returns
- IEnumerable<T>
A sequence of
Twith the shuffledsource.
Type Parameters
T
Remarks
Fisher–Yates shuffle: https://en.wikipedia.org/wiki/Fisher–Yates_shuffle