mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-30 06:13:11 +00:00
e5aa39a6bb
get language list now doesn't return new objects (or re-enumerate) update rand usage to be inclusive for top bound, extend shuffle to collections remove unnecessary location overrides (already overriden in legal fetch)
31 lines
854 B
C#
31 lines
854 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
public partial class Util
|
|
{
|
|
public static readonly Random Rand = new Random();
|
|
public static uint Rand32()
|
|
{
|
|
return (uint)Rand.Next(1 << 30) << 2 | (uint)Rand.Next(1 << 2);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Shuffles the order of items within a collection of items.
|
|
/// </summary>
|
|
/// <typeparam name="T">Item type</typeparam>
|
|
/// <param name="items">Item collection</param>
|
|
public static void Shuffle<T>(IList<T> items)
|
|
{
|
|
int n = items.Count;
|
|
for (int i = 0; i < n; i++)
|
|
{
|
|
int r = i + Rand.Next(n-i);
|
|
T t = items[r];
|
|
items[r] = items[i];
|
|
items[i] = t;
|
|
}
|
|
}
|
|
}
|
|
}
|