/// <summary>
/// 洗牌
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="_list"></param>
static internal List<T> Permute<T>(List<T> _list)
{
List<T> _listCopy = new List<T>(_list);
for (int i = 1; i < _listCopy.Count; i++)
{
Swap<T>(_listCopy, i, Random.Range(0, i));
}
return _listCopy;
}
static void Swap<T>(List<T> _list, int indexA, int indexB)
{
T temp = _list[indexA];
_list[indexA] = _list[indexB];
_list[indexB] = temp;
}
洗牌
最新推荐文章于 2018-05-08 14:13:59 发布