mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:05:42 +00:00
✨ Add IList<T> overloads for Shuffle<T>()
This commit is contained in:
parent
3b0c304f54
commit
d1d89de250
@ -69,5 +69,24 @@
|
|||||||
/// <returns>Returns <paramref name="source"/> shuffled.</returns>
|
/// <returns>Returns <paramref name="source"/> shuffled.</returns>
|
||||||
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source, Random random) =>
|
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source, Random random) =>
|
||||||
source.OrderBy(_ => random.Next());
|
source.OrderBy(_ => random.Next());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shuffles a list.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The collection type.</typeparam>
|
||||||
|
/// <param name="source">The collection to shuffle.</param>
|
||||||
|
/// <returns>Returns <paramref name="source"/> shuffled.</returns>
|
||||||
|
public static IEnumerable<T> Shuffle<T>(this IList<T> source) =>
|
||||||
|
source.Shuffle(new Random());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shuffles a list.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The collection type.</typeparam>
|
||||||
|
/// <param name="source">The collection to shuffle.</param>
|
||||||
|
/// <param name="random">The <see cref="Random"/> instance.</param>
|
||||||
|
/// <returns>Returns <paramref name="source"/> shuffled.</returns>
|
||||||
|
public static IEnumerable<T> Shuffle<T>(this IList<T> source, Random random) =>
|
||||||
|
source.OrderBy(_ => random.Next());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user