PKHeX/PKHeX.Core/Util/RandUtil.cs

25 lines
610 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 Rand32()
2016-07-09 22:30:12 +00:00
{
return (uint)Rand.Next(1 << 30) << 2 | (uint)Rand.Next(1 << 2);
2016-07-09 22:30:12 +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++)
{
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;
}
}
}
}