From 5d2233105fce4605a7e3eddaa35568d95fa5b743 Mon Sep 17 00:00:00 2001 From: wakfi <55608093+wakfi@users.noreply.github.com> Date: Mon, 7 Sep 2020 19:59:17 -0700 Subject: [PATCH] Add IterativeComb and SmartBogo to categories for RunAllSorts Length 11 on SmartBogoSort gives a good visual without being boringly long, which would be useful for video makers. It breaks the pattern of powers of 2 however, but there are currently no Delays built into the sort that would allow this to be manipulated using a speed modification instead. I put 8 for the length even though it's instant because 16 takes an obscene amount of time --- src/sorts/SmartBogoSort.java | 2 +- src/threads/RunExchangeSorts.java | 4 ++++ src/threads/RunImpracticalSorts.java | 8 ++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sorts/SmartBogoSort.java b/src/sorts/SmartBogoSort.java index c2cca708..cb6412f8 100644 --- a/src/sorts/SmartBogoSort.java +++ b/src/sorts/SmartBogoSort.java @@ -34,7 +34,7 @@ public SmartBogoSort(Delays delayOps, Highlights markOps, Reads readOps, Writes this.setSortPromptID("Smart Bogo"); this.setRunAllID("Permutation Sort"); this.setReportSortID("Permutation Sort"); - this.setCategory("Distributive Sorts"); + this.setCategory("Impractical Sorts"); this.isComparisonBased(false); this.isBucketSort(false); this.isRadixSort(false); diff --git a/src/threads/RunExchangeSorts.java b/src/threads/RunExchangeSorts.java index 5926f30c..242ffd64 100644 --- a/src/threads/RunExchangeSorts.java +++ b/src/threads/RunExchangeSorts.java @@ -8,6 +8,7 @@ import sorts.CombSort; import sorts.DualPivotQuickSort; import sorts.GnomeSort; +import sorts.IterativeCombSort; import sorts.LLQuickSort; import sorts.LRQuickSort; import sorts.OddEvenSort; @@ -61,6 +62,7 @@ final public class RunExchangeSorts extends MultipleSortThread { private Sort LRQuickSort; private Sort DualPivotQuickSort; private Sort StableQuickSort; + private Sort IterativeCombSort; public RunExchangeSorts(ArrayVisualizer ArrayVisualizer) { super(ArrayVisualizer); @@ -81,6 +83,7 @@ public RunExchangeSorts(ArrayVisualizer ArrayVisualizer) { LRQuickSort = new LRQuickSort(Delays, Highlights, Reads, Writes); DualPivotQuickSort = new DualPivotQuickSort(Delays, Highlights, Reads, Writes); StableQuickSort = new StableQuickSort(Delays, Highlights, Reads, Writes); + IterativeCombSort = new IterativeCombSort(Delays, Highlights, Reads, Writes); } @Override @@ -94,6 +97,7 @@ protected synchronized void executeSortList(int[] array) throws Exception { RunExchangeSorts.this.runIndividualSort(SmartGnomeSort, 0, array, 128, 0.025); RunExchangeSorts.this.runIndividualSort(BinaryGnomeSort, 0, array, 128, 0.025); RunExchangeSorts.this.runIndividualSort(CombSort, 0, array, 1024, 1); + RunExchangeSorts.this.runIndividualSort(IterativeCombSort, 0, array, 1024, 1); RunExchangeSorts.this.runIndividualSort(CircleSort, 0, array, 1024, 1); RunExchangeSorts.this.runIndividualSort(LLQuickSort, 0, array, 2048, ArrayManager.getShuffle() == Shuffles.RANDOM ? 1.5 : 65); RunExchangeSorts.this.runIndividualSort(LRQuickSort, 0, array, 2048, 1); diff --git a/src/threads/RunImpracticalSorts.java b/src/threads/RunImpracticalSorts.java index 69da1159..552dbca5 100644 --- a/src/threads/RunImpracticalSorts.java +++ b/src/threads/RunImpracticalSorts.java @@ -9,6 +9,7 @@ import sorts.LessBogoSort; import sorts.SillySort; import sorts.SlowSort; +import sorts.SmartBogoSort; import sorts.StoogeSort; import templates.JErrorPane; import templates.MultipleSortThread; @@ -49,13 +50,14 @@ final public class RunImpracticalSorts extends MultipleSortThread { private Sort BubbleBogoSort; private Sort LessBogoSort; private Sort CocktailBogoSort; + private Sort SmartBogoSort; private Sort BogoSort; - + public RunImpracticalSorts(ArrayVisualizer ArrayVisualizer) { super(ArrayVisualizer); this.sortCount = 9; this.categoryCount = this.sortCount; - + BadSort = new BadSort(Delays, Highlights, Reads, Writes); StoogeSort = new StoogeSort(Delays, Highlights, Reads, Writes); SillySort = new SillySort(Delays, Highlights, Reads, Writes); @@ -64,6 +66,7 @@ public RunImpracticalSorts(ArrayVisualizer ArrayVisualizer) { BubbleBogoSort = new BubbleBogoSort(Delays, Highlights, Reads, Writes); LessBogoSort = new LessBogoSort(Delays, Highlights, Reads, Writes); CocktailBogoSort = new CocktailBogoSort(Delays, Highlights, Reads, Writes); + SmartBogoSort = new SmartBogoSort(Delays, Highlights, Reads, Writes); BogoSort = new BogoSort(Delays, Highlights, Reads, Writes); } @@ -78,6 +81,7 @@ protected synchronized void executeSortList(int[] array) throws Exception { RunImpracticalSorts.this.runIndividualSort(BubbleBogoSort, 0, array, 32, 0.01); RunImpracticalSorts.this.runIndividualSort(LessBogoSort, 0, array, 16, 0.0025); RunImpracticalSorts.this.runIndividualSort(CocktailBogoSort, 0, array, 16, 0.0025); + RunImpracticalSorts.this.runIndividualSort(SmartBogoSort, 0, array, 8, 1); RunImpracticalSorts.this.runIndividualSort(BogoSort, 0, array, 8, 1); Sounds.toggleSofterSounds(false); }