using System;
using System.Collections.Generic;
namespace FishNet.Utility.Extension
{
public static class CollectionFN
{
///
/// Random for shuffling.
///
private static Random _random = new Random();
///
/// Shuffle based on Fisher-Yates shuffle.
/// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
/// https://stackoverflow.com/questions/273313/randomize-a-listt
///
public static void Shuffle(this IList lst)
{
int n = lst.Count;
while (n > 1)
{
n--;
int k = _random.Next(n + 1);
T value = lst[k];
lst[k] = lst[n];
lst[n] = value;
}
}
}
}