Example #1
0
 public static void InsertionSort <T> (this T[] array, SortOperation operation) where T : IComparable
 {
     for (int i = 1; i < array.Length; i++)
     {
         T   cur = array[i];
         int j   = i;
         while (j > 0 && cur.CompareAct(array[j - 1], operation) < 0)
         {
             array[j] = array[j - 1];
             j--;
         }
         array[j] = cur;
         operation.Swap();
     }
 }
Example #2
0
 public static void Swap <T> (this T[] array, int a, int b, SortOperation operation)
 {
     Swap(array, a, b);
     operation.Swap();
 }