25 lines
603 B
C#
25 lines
603 B
C#
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using Random = System.Random;
|
||
|
|
|
||
|
|
namespace Framework
|
||
|
|
{
|
||
|
|
public class Algorithm
|
||
|
|
{
|
||
|
|
public static void ShuffleInPlace<T>(IList<T> list)
|
||
|
|
{
|
||
|
|
var random = new Random(Time.frameCount);
|
||
|
|
|
||
|
|
for (int i = 0; i < list.Count - 1; i++)
|
||
|
|
{
|
||
|
|
int j = random.Next(i, list.Count);
|
||
|
|
if (i != j)
|
||
|
|
{
|
||
|
|
T temp = list[j];
|
||
|
|
list[j] = list[i];
|
||
|
|
list[i] = temp;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|