aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Extensions/ShuffleExtensions.cs
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2021-10-26 17:43:36 -0600
committerCody Robibero <cody@robibe.ro>2021-10-26 17:43:36 -0600
commitf78f1e834ce1907157d4d43cf8564cf40d05fb9f (patch)
treebeb4e348e4d338a8b459f8a421ba19409d478ba9 /MediaBrowser.Common/Extensions/ShuffleExtensions.cs
parent2888567ea53c1c839b0cd69e0ec1168cf51f36a8 (diff)
parent39d5bdac96b17eb92bd304736cc2728832e1cad0 (diff)
Merge remote-tracking branch 'upstream/master' into client-logger
Diffstat (limited to 'MediaBrowser.Common/Extensions/ShuffleExtensions.cs')
-rw-r--r--MediaBrowser.Common/Extensions/ShuffleExtensions.cs43
1 files changed, 0 insertions, 43 deletions
diff --git a/MediaBrowser.Common/Extensions/ShuffleExtensions.cs b/MediaBrowser.Common/Extensions/ShuffleExtensions.cs
deleted file mode 100644
index 6f0ea9bd5..000000000
--- a/MediaBrowser.Common/Extensions/ShuffleExtensions.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-#nullable enable
-
-using System;
-using System.Collections.Generic;
-
-namespace MediaBrowser.Common.Extensions
-{
- /// <summary>
- /// Provides <c>Shuffle</c> extensions methods for <see cref="IList{T}" />.
- /// </summary>
- public static class ShuffleExtensions
- {
- private static readonly Random _rng = new Random();
-
- /// <summary>
- /// Shuffles the items in a list.
- /// </summary>
- /// <param name="list">The list that should get shuffled.</param>
- /// <typeparam name="T">The type.</typeparam>
- public static void Shuffle<T>(this IList<T> list)
- {
- list.Shuffle(_rng);
- }
-
- /// <summary>
- /// Shuffles the items in a list.
- /// </summary>
- /// <param name="list">The list that should get shuffled.</param>
- /// <param name="rng">The random number generator to use.</param>
- /// <typeparam name="T">The type.</typeparam>
- public static void Shuffle<T>(this IList<T> list, Random rng)
- {
- int n = list.Count;
- while (n > 1)
- {
- int k = rng.Next(n--);
- T value = list[k];
- list[k] = list[n];
- list[n] = value;
- }
- }
- }
-}