コード例 #1
0
        public static void Show()
        {
            int[] arr = new int[]
            {
                10000, 20000, 30000, 40000, 50000,
                100000, 200000, 500000,
                1000000, 2000000, 5000000, 10000000,
                100000000
            };

            foreach (int i in arr)
            {
                Console.WriteLine("Длина массива - " + i);

                int[] array = IntArrayGenerator.GenerateArray(i);
                Console.WriteLine("быстрая сортировка " + ", время выполнения - " +
                                  ActionTimeMeasurer.Measure(new Action(() =>
                                                                        HoareSorter.Sort(array))));

                array = IntArrayGenerator.GenerateArray(i);
                Console.WriteLine("встроенная сортировка " + ", время выполнения - " +
                                  ActionTimeMeasurer.Measure(new Action(() =>
                                                                        Array.Sort(array))));

                array = IntArrayGenerator.GenerateArray(i);
                Console.WriteLine("сортировка слиянием " + ", время выполнения - " +
                                  ActionTimeMeasurer.Measure(new Action(() =>
                                                                        MergeSorter.Sort(array))));
                GC.Collect();
                Console.WriteLine();
            }

            Console.ReadKey();
        }
コード例 #2
0
        public void HoareSortTest()
        {
            int[] arr = IntArrayGenerator.GenerateArray(1000);
            HoareSorter.Sort(arr);
            int el = int.MinValue;

            for (int i = 0; i < arr.Length; i++)
            {
                if (el > arr[i])
                {
                    Assert.Fail();
                }
                el = arr[i];
            }
        }