예제 #1
0
        public RadixLSD10SortTests()
        {
            var sort = new RadixLSD10Sort <int>();

            func      = array => sort.Sort(array);
            this.sort = sort;
            algorithm = nameof(RadixLSD10Sort <int>);
        }
예제 #2
0
        public void Run(IInputSample <int>[] items)
        {
            foreach (var item in items)
            {
                if (item.Samples != null)
                {
                    Init(item.Samples);

                    // -- Exchange -- //

                    // Bubble Sort
                    RunSort(new BubbleSort <int>(), item);

                    // OddEven Sort
                    RunSort(new OddEvenSort <int>(), item);

                    // Cocktail Shaker Sort
                    RunSort(new CocktailShakerSort <int>(), item);
                    RunSort(new CocktailShakerSort2 <int>(), item);

                    // Comb Sort
                    RunSort(new CombSort <int>(), item);

                    // Cycle Sort
                    RunSort(new CycleSort <int>(), item);

                    // Stooge Sort
                    RunSort(new StoogeSort <int>(), item);

                    // Too slow....
                    if (item.Samples.Length < 100)
                    {
                        // Bogo Sort
                        RunSort(new BogoSort <int>(), item);
                    }

                    if (item.Samples.Length < 1000)
                    {
                        // Slow Sort
                        RunSort(new SlowSort <int>(), item);
                    }

                    // Gnome Sort
                    RunSort(new GnomeSort <int>(), item);
                    RunSort(new GnomeSort1 <int>(), item);
                    RunSort(new GnomeSort2 <int>(), item);
                    RunSort(new GnomeSort3 <int>(), item);

                    // -- Selection -- //

                    // Selection Sort
                    RunSort(new SelectionSort <int>(), item);

                    // Heap Sort
                    RunSort(new HeapSort <int>(), item);

                    // Smooth Sort
                    RunSort(new SmoothSort <int>(), item);

                    // -- Insertion -- //

                    // Insert Sort
                    RunSort(new InsertSort <int>(), item);

                    // Binary Insert Sort
                    RunSort(new BinaryInsertSort <int>(), item);

                    // Shell Sort
                    RunSort(new ShellSort <int>(), item);

                    // Binary Tree Sort
                    RunSort(new BinaryTreeSort <int>(), item);

                    // -- Partitionig -- //

                    // Quick Sort Median3
                    RunSort(new QuickSortMedian3 <int>(), item);

                    // Quick Sort Median9
                    RunSort(new QuickSortMedian9 <int>(), item);

                    // Dual Pivot QuickSort
                    RunSort(new QuickDualPivotSort <int>(), item);

                    // QuickSort Median3 (Quick + Insert)
                    RunSort(new QuickSortMedian3Insert <int>(), item);

                    // QuickSort Median9 (Quick + Insert)
                    RunSort(new QuickSortMedian9Insert <int>(), item);

                    // Dual Pivot Quick Sort (Quick + Insert)
                    RunSort(new QuickDualPivotSortInsert <int>(), item);

                    // QuickSort Median3 (Quick + BinaryInsert)
                    RunSort(new QuickSortMedian3BinaryInsert <int>(), item);

                    // QuickSort Median9 (Quick + BinaryInsert)
                    RunSort(new QuickSortMedian9BinaryInsert <int>(), item);

                    // Dual Pivot Quick Sort (Quick + BinaryInsert)
                    RunSort(new QuickDualPivotSortBinaryInsert <int>(), item);

                    // -- Merge -- //

                    // Merge Sort
                    RunSort(new MergeSort <int>(), item);
                    RunSort(new MergeSort2 <int>(), item);

                    // Shift Sort
                    RunSort(new ShiftSort <int>(), item);

                    // DropMerge Sort
                    RunSort(new DropMergeSort <int>(), item);

                    // -- Distribution -- //

                    // Bucket Sort
                    var bucketSort = new BucketSort <int>();
                    RunSort(bucketSort, array => bucketSort.Sort(array), item);

                    // Radix Sort(LSD)
                    var radix10Sort = new RadixLSD10Sort <int>();
                    RunSort(radix10Sort, array => radix10Sort.Sort(array), item);

                    var radix4Sort = new RadixLSD4Sort <int>();
                    RunSort(radix4Sort, array => radix4Sort.Sort(array), item);

                    // Counting Sort
                    var countingSort = new CountingSort <int>();
                    RunSort(countingSort, array => countingSort.Sort(array), item);

                    // -- Hybrid -- //

                    // IntroSort Median3 (Quick + Heap + Insert)
                    //RunSort(new IntroSortMedian3<int>(), item);

                    // IntroSort Median9 (Quick + Heap + Insert)
                    RunSort(new IntroSortMedian9 <int>(), item);

                    // IntroSort Median9 (Insert + Merge)
                    //RunSort(new TimSort<int>(), item);

                    // -- Other -- //

                    // Pancake Sort
                    RunSort(new PancakeSort <int>(), item);
                }

                // BucketSort<T>
                if (item.Samples == null && item.DictionarySamples != null)
                {
                    Init(item.DictionarySamples);

                    // -- Distribution -- //

                    RunBucketTSort(new BucketSortT <KeyValuePair <int, string> >(), x => x.Key, item.DictionarySamples.Max(x => x.Key), item);
                }
            }
        }