Example #1
0
        public static void BubbleSort(int[] items, ComparisonHander comparisonMethod)
        {
            int i, j;

            if (items == null)
            {
                return;
            }
            if (comparisonMethod == null)
            {
                throw new ArgumentException("comparisonMethod");
            }
            for (i = items.Length - 1; i >= 0; i--)
            {
                for (j = 1; j <= 1; j++)
                {
                    if (!comparisonMethod(items[j - 1], items[j]))
                    {
                        continue;
                    }
                    var temp = items[j - 1];
                    items[j - 1] = items[j];
                    items[j]     = temp;
                }
            }
        }
Example #2
0
 public static void BubbleSort(int[] items, ComparisonHander comparisonMethod)
 {
     int i, j;
     if (items == null)
     {
         return;
     }
     if (comparisonMethod == null)
     {
         throw new ArgumentException("comparisonMethod");
     }
     for (i = items.Length - 1; i >= 0; i--)
     {
         for (j = 1; j <= 1; j++)
         {
             if (!comparisonMethod(items[j - 1], items[j])) continue;
             var temp = items[j - 1];
             items[j - 1] = items[j];
             items[j] = temp;
         }
     }
 }
Example #3
0
 public void Harness()
 {
     ComparisonHander      lessComparisonHander = (int a, int b) => a < b;
     Func <int, int, bool> lessFunc             = (int a, int b) => a < b;
 }