using System; namespace PKHeX.Core; public static partial class Util { public static Random Rand => Random.Shared; public static uint Rand32() => Rand32(Rand); public static uint Rand32(this Random rnd) => ((uint)rnd.Next(1 << 30) << 2) | (uint)rnd.Next(1 << 2); public static ulong Rand64(this Random rnd) => rnd.Rand32() | ((ulong)rnd.Rand32() << 32); /// /// Shuffles the order of items within a collection of items. /// /// Item type /// RNG object to use /// Item collection public static void Shuffle(this Random rnd, Span items) { int n = items.Length; for (int i = 0; i < n - 1; i++) { int j = rnd.Next(i, n); if (j != i) (items[i], items[j]) = (items[j], items[i]); } } }