2016-07-09 22:30:12 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2016-07-09 22:30:12 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class Util
|
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public static readonly Random Rand = new Random();
|
|
|
|
|
public static uint Rand32()
|
2016-07-09 22:30:12 +00:00
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
return (uint)Rand.Next(1 << 30) << 2 | (uint)Rand.Next(1 << 2);
|
2016-07-09 22:30:12 +00:00
|
|
|
|
}
|
2017-01-08 07:54:09 +00:00
|
|
|
|
public static void Shuffle<T>(T[] array)
|
2016-07-09 22:30:12 +00:00
|
|
|
|
{
|
|
|
|
|
int n = array.Length;
|
|
|
|
|
for (int i = 0; i < n; i++)
|
|
|
|
|
{
|
2017-06-18 01:37:19 +00:00
|
|
|
|
int r = i + (int)(Rand.NextDouble() * (n - i));
|
2016-07-09 22:30:12 +00:00
|
|
|
|
T t = array[r];
|
|
|
|
|
array[r] = array[i];
|
|
|
|
|
array[i] = t;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|