PKHeX/PKHeX.Core/Util/RandUtil.cs

25 lines
609 B
C#
Raw Normal View History

2016-07-09 22:30:12 +00:00
using System;
namespace PKHeX.Core
2016-07-09 22:30:12 +00:00
{
public partial class Util
{
public static readonly Random rand = new Random();
public static uint rnd32()
2016-07-09 22:30:12 +00:00
{
return (uint)rand.Next(1 << 30) << 2 | (uint)rand.Next(1 << 2);
}
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++)
{
int r = i + (int)(rand.NextDouble() * (n - i));
T t = array[r];
array[r] = array[i];
array[i] = t;
}
}
}
}