diff --git a/ListShuffle/ListExtensions.cs b/ListShuffle/ListExtensions.cs index 9743b2a..fadd080 100644 --- a/ListShuffle/ListExtensions.cs +++ b/ListShuffle/ListExtensions.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; +using ThreadSafeRandomizer; namespace ListShuffle { @@ -21,7 +21,7 @@ public static void Shuffle(this IList list) while (n > 1) { n--; - int k = ThreadSafeRandom.Next(n + 1); + int k = ThreadSafeRandom.Instance.Next(n + 1); (list[n], list[k]) = (list[k], list[n]); } } diff --git a/ListShuffle/ListShuffle.csproj b/ListShuffle/ListShuffle.csproj index bfb25bd..c9f0602 100644 --- a/ListShuffle/ListShuffle.csproj +++ b/ListShuffle/ListShuffle.csproj @@ -6,16 +6,16 @@ https://github.com/MarkCiliaVincenti/ListShuffle.git https://github.com/MarkCiliaVincenti/ListShuffle LICENSE - 1.0.4 + 1.0.5 logo.png - Updated documentation and tests packages. + Added dependency on ThreadSafeRandomizer. Thread-safe list shuffle extension library, using Fisher-Yates shuffle. © 2022 Mark Cilia Vincenti list,shuffle,shuffler,extension,threadsafe,thread-safe git True - 1.0.4.0 - 1.0.4.0 + 1.0.5.0 + 1.0.5.0 README.md true True @@ -43,4 +43,8 @@ + + + + diff --git a/ListShuffle/ThreadSafeRandom.cs b/ListShuffle/ThreadSafeRandom.cs deleted file mode 100644 index d4879de..0000000 --- a/ListShuffle/ThreadSafeRandom.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Threading; - -namespace ListShuffle -{ - internal class ThreadSafeRandom - { - private static readonly Random _global = new Random(); - private static readonly ThreadLocal _local = new ThreadLocal(() => - { - int seed; - lock (_global) - { - seed = _global.Next(); - } - return new Random(seed); - }); - - public static int Next(int maxValue) - { - return _local.Value.Next(maxValue); - } - } -}