Пример #1
0
 public static T[] Shuffle <T>(this IEnumerable <T> enumerable)
 {
     T[] arr = enumerable.ToArray();
     for (int i = arr.Length - 1; i >= 0; i--)
     {
         int j    = RandomAid.NextInt(i + 1);
         T   temp = arr[j];
         arr[j] = arr[i];
         arr[i] = temp;
     }
     return(arr);
 }
Пример #2
0
 private static int Partition <T>(this IList <T> list, Func <T, T, int> comparison, IntRange indices)
 {
     return(list.Partition(RandomAid.NextInt(indices), comparison, indices));
 }