27 lines
705 B
C#
27 lines
705 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace MafiaCommon
|
|
{
|
|
public static class ListUtils
|
|
{
|
|
public static void Shuffle<T> (this Random rng, T[] array)
|
|
{
|
|
int n = array.Length;
|
|
while (n > 1)
|
|
{
|
|
int k = rng.Next(n--);
|
|
T temp = array[n];
|
|
array[n] = array[k];
|
|
array[k] = temp;
|
|
}
|
|
}
|
|
|
|
public static T[] RemoveFromArray<T> (this T[] original, int numIdx) {
|
|
if (numIdx == -1) return original;
|
|
List<T> tmp = new List<T>(original);
|
|
tmp.RemoveAt(numIdx);
|
|
return tmp.ToArray();
|
|
}
|
|
}
|
|
} |