示例#1
0
        public static void StartSortInThread(string[] arr)
        {
            SortDelegate del = new SortDelegate(Sorting);

            del?.Invoke(arr);

            Thread t = new Thread(delegate() { Sorting(arr); });

            t.Start();
            Thread.Sleep(500);
        }
示例#2
0
 public static void Sort(List <int> list, SortDelegate del)
 {
     for (int i = 1; i < list.Count; i++)
     {
         for (int j = 0; j < list.Count - i; j++)
         {
             if (del.Invoke(list[j], list[j + 1]) > 0)
             {
                 int temp = list[j];
                 list[j]     = list[j + 1];
                 list[j + 1] = temp;
             }
         }
     }
 }
示例#3
0
        public double GetSortingTime(SortDelegate sortDelegate, long[] array)
        {
            double    result;
            Stopwatch stopwatch = new Stopwatch();

            for (int i = 0; i < iterations; i++)
            {
                long[] tempArray = new long[array.Length];
                Array.Copy(array, tempArray, array.Length);

                stopwatch.Start();
                sortDelegate.Invoke(tempArray);
                stopwatch.Stop();
            }
            result = stopwatch.Elapsed.TotalMilliseconds / Iterations;
            return(result);
        }