diff options
| author | Cody Robibero <cody@robibe.ro> | 2021-08-04 06:24:58 -0600 |
|---|---|---|
| committer | Cody Robibero <cody@robibe.ro> | 2021-08-04 06:24:58 -0600 |
| commit | 398ca85944c21609156892dd8c5560126336f11b (patch) | |
| tree | 5ccd6d959a64a262e1db4a1583619e30775edb68 /MediaBrowser.Common/Extensions/ShuffleExtensions.cs | |
| parent | d212b6fb08fc8d45008499f3dfce33f59bb425e3 (diff) | |
| parent | 1b8eb1aefe2a10b9671e801e8b1feeb8e2362c87 (diff) | |
Merge remote-tracking branch 'upstream/master' into baseitemkind-fixes
Diffstat (limited to 'MediaBrowser.Common/Extensions/ShuffleExtensions.cs')
| -rw-r--r-- | MediaBrowser.Common/Extensions/ShuffleExtensions.cs | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/MediaBrowser.Common/Extensions/ShuffleExtensions.cs b/MediaBrowser.Common/Extensions/ShuffleExtensions.cs deleted file mode 100644 index 2604abf85..000000000 --- a/MediaBrowser.Common/Extensions/ShuffleExtensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -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; - } - } - } -} |
