Skip to content

Commit

Permalink
Revamp RunSortBuilder somewhat
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Apr 4, 2022
1 parent 5054f51 commit b4aa443
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 199 deletions.
50 changes: 27 additions & 23 deletions src/main/java/io/github/arrayv/groovyapi/RunSortBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,50 +103,54 @@ public String toString() {

/**
* Merge the specified options with the options map
* @param opts The options to merge, generally obtained with {@link RunSortInfoExtension}
* @param optsMap The options to merge, generally using Groovy's keyword argument syntax
* @param optsEntries The options to merge, generally obtained with {@link RunSortInfoExtension}
* @return {@code this} for chaining
* @see RunSortInfoExtension
*/
@SafeVarargs
public final RunSortBuilder with(Map.Entry<String, Object>... opts) {
for (Map.Entry<String, Object> opt : opts) {
public final RunSortBuilder with(Map<String, Object> optsMap, Map.Entry<String, Object>... optsEntries) {
if (optsMap != null) {
for (Map.Entry<String, Object> opt : optsMap.entrySet()) {
put(opt);
}
}
for (Map.Entry<String, Object> opt : optsEntries) {
put(opt);
}
return this;
}

/**
* Merge the specified options with the options map
* @param opts The options to merge
* @param opts The options to merge, generally obtained with {@link RunSortInfoExtension}
* @return {@code this} for chaining
* @see RunSortInfoExtension
*/
public RunSortBuilder with(Map<String, Object> opts) {
for (Map.Entry<String, Object> opt : opts.entrySet()) {
put(opt);
}
return this;
@SafeVarargs
public final RunSortBuilder with(Map.Entry<String, Object>... opts) {
return with(null, opts);
}

/**
* <p>Put one more option into the options map and run the sort</p>
* Equivalent to {@code with(opt).go()} or {@code with opt go()}
* @param opt The option to add
* Merge the specified options with the options map, and run the sort
* @param optsMap The options to merge, generally using Groovy's keyword argument syntax
* @param optsEntries The options to merge, generally obtained with {@link RunSortInfoExtension}
* @see RunSortInfoExtension
*/
public void and(Map.Entry<String, Object> opt) {
put(opt);
finish();
@SafeVarargs
public final void go(Map<String, Object> optsMap, Map.Entry<String, Object>... optsEntries) {
with(optsMap, optsEntries).finish();
}

/**
* Run the sort
* Merge the specified options with the options map, and run the sort
* @param opts The options to merge, generally obtained with {@link RunSortInfoExtension}
* @see RunSortInfoExtension
*/
public void run(Map<String, Object> opts) {
if (opts != null) {
for (Map.Entry<String, Object> opt : opts.entrySet()) {
put(opt);
}
}
finish();
@SafeVarargs
public final void go(Map.Entry<String, Object>... opts) {
go(null, opts);
}

private void put(Map.Entry<String, Object> opt) {
Expand Down
44 changes: 22 additions & 22 deletions src/main/resources/scripts/categories/concurrent.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@ import io.github.arrayv.prompts.SortPrompt

SortPrompt.setSortThreadForCategory('Concurrent Sorts', 22) {
// Other
run FoldSort with 1024.numbers run()
run CreaseSort with 1024.numbers run()
run MatrixSort with 256.numbers and 0.667.speed
run FoldSort go 1024.numbers
run CreaseSort go 1024.numbers
run MatrixSort go 256.numbers, 0.667.speed

// Recursive
run BitonicSortRecursive with 1024.numbers run()
run OddEvenMergeSortRecursive with 1024.numbers run()
run PairwiseSortRecursive with 1024.numbers run()
run BoseNelsonSortRecursive with 1024.numbers run()
run WeaveSortRecursive with 1024.numbers run()
run DiamondSortRecursive with 1024.numbers run()
run PairwiseMergeSortRecursive with 1024.numbers run()
run BitonicSortRecursive go 1024.numbers
run OddEvenMergeSortRecursive go 1024.numbers
run PairwiseSortRecursive go 1024.numbers
run BoseNelsonSortRecursive go 1024.numbers
run WeaveSortRecursive go 1024.numbers
run DiamondSortRecursive go 1024.numbers
run PairwiseMergeSortRecursive go 1024.numbers

// Parallel
run BitonicSortParallel with 1024.numbers run()
run OddEvenMergeSortParallel with 1024.numbers run()
run BoseNelsonSortParallel with 1024.numbers run()
run WeaveSortParallel with 1024.numbers run()
run BitonicSortParallel go 1024.numbers
run OddEvenMergeSortParallel go 1024.numbers
run BoseNelsonSortParallel go 1024.numbers
run WeaveSortParallel go 1024.numbers

// Iterative
run BitonicSortIterative with 1024.numbers run()
run OddEvenMergeSortIterative with 1024.numbers run()
run PairwiseSortIterative with 1024.numbers run()
run BoseNelsonSortIterative with 1024.numbers run()
run WeaveSortIterative with 1024.numbers run()
run MergeExchangeSortIterative with 1024.numbers run()
run DiamondSortIterative with 1024.numbers run()
run PairwiseMergeSortIterative with 1024.numbers run()
run BitonicSortIterative go 1024.numbers
run OddEvenMergeSortIterative go 1024.numbers
run PairwiseSortIterative go 1024.numbers
run BoseNelsonSortIterative go 1024.numbers
run WeaveSortIterative go 1024.numbers
run MergeExchangeSortIterative go 1024.numbers
run DiamondSortIterative go 1024.numbers
run PairwiseMergeSortIterative go 1024.numbers
}
36 changes: 18 additions & 18 deletions src/main/resources/scripts/categories/distribute.groovy
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import io.github.arrayv.prompts.SortPrompt

SortPrompt.setSortThreadForCategory('Distribution Sorts', 18) {
run CountingSort with 2048.numbers and 1.5.speed
run PigeonholeSort with 2048.numbers and 1.5.speed
run GravitySort with 1024.numbers and 0.5.speed
run ClassicGravitySort with 1024.numbers run()
run StaticSort with 2048.numbers run()
run IndexSort with 2048.numbers run()
run AmericanFlagSort with 2048.numbers, 128.buckets and 0.75.speed
run StacklessAmericanFlagSort with 2048.numbers, 128.buckets and 0.75.speed
run LSDRadixSort with 2048.numbers, 4.buckets and 1.5.speed
run CountingSort go 2048.numbers, 1.5.speed
run PigeonholeSort go 2048.numbers, 1.5.speed
run GravitySort go 1024.numbers, 0.5.speed
run ClassicGravitySort go 1024.numbers
run StaticSort go 2048.numbers
run IndexSort go 2048.numbers
run AmericanFlagSort go 2048.numbers, 128.buckets, 0.75.speed
run StacklessAmericanFlagSort go 2048.numbers, 128.buckets, 0.75.speed
run LSDRadixSort go 2048.numbers, 4.buckets, 1.5.speed

def oldSofterSounds = arrayv.sounds.softerSounds
arrayv.sounds.softerSounds = true
run InPlaceLSDRadixSort with 2048.numbers and 10.buckets
run InPlaceLSDRadixSort go 2048.numbers, 10.buckets
arrayv.sounds.softerSounds = oldSofterSounds

run MSDRadixSort with 2048.numbers, 4.buckets and 1.25.speed
run FlashSort with 2048.numbers run()
run BinaryQuickSortIterative with 2048.numbers run()
run BinaryQuickSortRecursive with 2048.numbers run()
run StacklessBinaryQuickSort with 2048.numbers run()
run ShatterSort with 2048.numbers, 128.buckets run()
run SimpleShatterSort with 2048.numbers and 128.buckets
run TimeSort with 512.numbers, 10.buckets and 0.05.speed
run MSDRadixSort go 2048.numbers, 4.buckets, 1.25.speed
run FlashSort go 2048.numbers
run BinaryQuickSortIterative go 2048.numbers
run BinaryQuickSortRecursive go 2048.numbers
run StacklessBinaryQuickSort go 2048.numbers
run ShatterSort go 2048.numbers, 128.buckets
run SimpleShatterSort go 2048.numbers, 128.buckets
run TimeSort go 512.numbers, 10.buckets, 0.05.speed
}
58 changes: 29 additions & 29 deletions src/main/resources/scripts/categories/exchange.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@ import io.github.arrayv.prompts.SortPrompt
import io.github.arrayv.utils.Shuffles

SortPrompt.setSortThreadForCategory('Exchange Sorts', 29) {
run UnoptimizedBubbleSort with 512.numbers and 1.5.speed
run BubbleSort with 512.numbers and 1.5.speed
run OptimizedBubbleSort with 512.numbers and 1.5.speed
run UnoptimizedCocktailShakerSort with 512.numbers and 1.25.speed
run CocktailShakerSort with 512.numbers and 1.25.speed
run OptimizedCocktailShakerSort with 512.numbers and 1.25.speed
run OddEvenSort with 512.numbers run()
run OptimizedStoogeSort with 512.numbers run()
run OptimizedStoogeSortStudio with 512.numbers run()
run FunSort with 256.numbers and 2.speed
run GnomeSort with 128.numbers and 0.025.speed
run OptimizedGnomeSort with 128.numbers and 0.025.speed
run BinaryGnomeSort with 128.numbers and 0.025.speed
run SlopeSort with 128.numbers and 0.025.speed
run CombSort with 1024.numbers and 130.buckets
run ThreeSmoothCombSortRecursive with 1024.numbers and 1.25.speed
run ThreeSmoothCombSortParallel with 1024.numbers and 1.25.speed
run ThreeSmoothCombSortIterative with 1024.numbers and 1.25.speed
run ClassicThreeSmoothCombSort with 1024.numbers and 1.25.speed
run CircleSortRecursive with 1024.numbers run()
run CircleSortIterative with 1024.numbers run()
run LLQuickSort with 2048.numbers and ((arrayv.arrayManager.containsShuffle(Shuffles.RANDOM) ? 1.5 : 5).speed)
run LRQuickSort with 2048.numbers run()
run LRQuickSortParallel with 2048.numbers run()
run DualPivotQuickSort with 2048.numbers run()
run StableQuickSort with 2048.numbers and ((arrayv.arrayManager.containsShuffle(Shuffles.RANDOM) ? 1 : 6.5).speed)
run StableQuickSortParallel with 2048.numbers run()
run ForcedStableQuickSort with 2048.numbers run()
run TableSort with 1024.numbers and 0.75.speed
run UnoptimizedBubbleSort go 512.numbers, 1.5.speed
run BubbleSort go 512.numbers, 1.5.speed
run OptimizedBubbleSort go 512.numbers, 1.5.speed
run UnoptimizedCocktailShakerSort go 512.numbers, 1.25.speed
run CocktailShakerSort go 512.numbers, 1.25.speed
run OptimizedCocktailShakerSort go 512.numbers, 1.25.speed
run OddEvenSort go 512.numbers
run OptimizedStoogeSort go 512.numbers
run OptimizedStoogeSortStudio go 512.numbers
run FunSort go 256.numbers, 2.speed
run GnomeSort go 128.numbers, 0.025.speed
run OptimizedGnomeSort go 128.numbers, 0.025.speed
run BinaryGnomeSort go 128.numbers, 0.025.speed
run SlopeSort go 128.numbers, 0.025.speed
run CombSort go 1024.numbers, 130.buckets
run ThreeSmoothCombSortRecursive go 1024.numbers, 1.25.speed
run ThreeSmoothCombSortParallel go 1024.numbers, 1.25.speed
run ThreeSmoothCombSortIterative go 1024.numbers, 1.25.speed
run ClassicThreeSmoothCombSort go 1024.numbers, 1.25.speed
run CircleSortRecursive go 1024.numbers
run CircleSortIterative go 1024.numbers
run LLQuickSort go 2048.numbers, ((arrayv.arrayManager.containsShuffle(Shuffles.RANDOM) ? 1.5 : 5).speed)
run LRQuickSort go 2048.numbers
run LRQuickSortParallel go 2048.numbers
run DualPivotQuickSort go 2048.numbers
run StableQuickSort go 2048.numbers, ((arrayv.arrayManager.containsShuffle(Shuffles.RANDOM) ? 1 : 6.5).speed)
run StableQuickSortParallel go 2048.numbers
run ForcedStableQuickSort go 2048.numbers
run TableSort go 1024.numbers, 0.75.speed
}
64 changes: 32 additions & 32 deletions src/main/resources/scripts/categories/hybrid.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@ import io.github.arrayv.prompts.SortPrompt
import io.github.arrayv.utils.Shuffles

SortPrompt.setSortThreadForCategory('Hybrid Sorts', 32) {
run HybridCombSort with 1024.numbers run()
run IntroCircleSortRecursive with 1024.numbers run()
run IntroCircleSortIterative with 1024.numbers run()
run BinaryMergeSort with 2048.numbers run()
run MergeInsertionSort with 2048.numbers and 1.75.speed
run WeaveMergeSort with 2048.numbers and ((arrayv.arrayManager.containsShuffle(Shuffles.RANDOM) ? 1.65 : 6.5).speed)
run TimSort with 2048.numbers run()
run CocktailMergeSort with 2048.numbers run()
run LaziestSort with 1024.numbers run()
run WikiSort with 2048.numbers run()
run GrailSort with 2048.numbers run()
run AdaptiveGrailSort with 2048.numbers run()
run UnstableGrailSort with 2048.numbers run()
run SqrtSort with 2048.numbers run()
run KotaSort with 2048.numbers run()
run EctaSort with 2048.numbers run()
run ParallelBlockMergeSort with 2048.numbers run()
run ParallelGrailSort with 2048.numbers run()
run FlanSort with 2048.numbers run()
run RemiSort with 2048.numbers run()
run ImprovedBlockSelectionSort with 2048.numbers run()
run MedianMergeSort with 2048.numbers run()
run BufferPartitionMergeSort with 2048.numbers run()
run IntroSort with 2048.numbers run()
run OptimizedBottomUpMergeSort with 2048.numbers run()
run OptimizedDualPivotQuickSort with 2048.numbers and 0.75.speed
run OptimizedWeaveMergeSort with 1024.numbers and 0.4.speed
run StacklessHybridQuickSort with 2048.numbers and 0.75.speed
run StacklessDualPivotQuickSort with 2048.numbers and 0.75.speed
run PDQBranchedSort with 2048.numbers and 0.75.speed
run PDQBranchlessSort with 2048.numbers and 0.75.speed
run DropMergeSort with 2048.numbers and 0.75.speed
run HybridCombSort go 1024.numbers
run IntroCircleSortRecursive go 1024.numbers
run IntroCircleSortIterative go 1024.numbers
run BinaryMergeSort go 2048.numbers
run MergeInsertionSort go 2048.numbers, 1.75.speed
run WeaveMergeSort go 2048.numbers, ((arrayv.arrayManager.containsShuffle(Shuffles.RANDOM) ? 1.65 : 6.5).speed)
run TimSort go 2048.numbers
run CocktailMergeSort go 2048.numbers
run LaziestSort go 1024.numbers
run WikiSort go 2048.numbers
run GrailSort go 2048.numbers
run AdaptiveGrailSort go 2048.numbers
run UnstableGrailSort go 2048.numbers
run SqrtSort go 2048.numbers
run KotaSort go 2048.numbers
run EctaSort go 2048.numbers
run ParallelBlockMergeSort go 2048.numbers
run ParallelGrailSort go 2048.numbers
run FlanSort go 2048.numbers
run RemiSort go 2048.numbers
run ImprovedBlockSelectionSort go 2048.numbers
run MedianMergeSort go 2048.numbers
run BufferPartitionMergeSort go 2048.numbers
run IntroSort go 2048.numbers
run OptimizedBottomUpMergeSort go 2048.numbers
run OptimizedDualPivotQuickSort go 2048.numbers, 0.75.speed
run OptimizedWeaveMergeSort go 1024.numbers, 0.4.speed
run StacklessHybridQuickSort go 2048.numbers, 0.75.speed
run StacklessDualPivotQuickSort go 2048.numbers, 0.75.speed
run PDQBranchedSort go 2048.numbers, 0.75.speed
run PDQBranchlessSort go 2048.numbers, 0.75.speed
run DropMergeSort go 2048.numbers, 0.75.speed
}
48 changes: 24 additions & 24 deletions src/main/resources/scripts/categories/impractical.groovy
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import io.github.arrayv.prompts.SortPrompt

SortPrompt.setSortThreadForCategory('Impractical Sorts', 32) {
run BadSort with 64.numbers and 0.0075.speed
run StoogeSort with 64.numbers and 0.005.speed
run QuadStoogeSort with 64.numbers and 0.005.speed
run SillySort with 64.numbers and 0.5.speed
run SlowSort with 64.numbers and 0.5.speed
run SnuffleSort with 64.numbers and 0.25.speed
run HanoiSort with 8.numbers and 0.025.speed
run BadSort go 64.numbers, 0.0075.speed
run StoogeSort go 64.numbers, 0.005.speed
run QuadStoogeSort go 64.numbers, 0.005.speed
run SillySort go 64.numbers, 0.5.speed
run SlowSort go 64.numbers, 0.5.speed
run SnuffleSort go 64.numbers, 0.25.speed
run HanoiSort go 8.numbers, 0.025.speed

// Bogosorts
def oldSofterSounds = arrayv.sounds.softerSounds
arrayv.sounds.softerSounds = true
// The not-bad ones
run SelectionBogoSort with 64.numbers and 1e-9.speed
run BubbleBogoSort with 40.numbers and 1e-9.speed
run CocktailBogoSort with 40.numbers and 1e-9.speed
run LessBogoSort with 32.numbers and 1e-9.speed
run ExchangeBogoSort with 28.numbers and 1e-9.speed
run SelectionBogoSort go 64.numbers, 1e-9.speed
run BubbleBogoSort go 40.numbers, 1e-9.speed
run CocktailBogoSort go 40.numbers, 1e-9.speed
run LessBogoSort go 32.numbers, 1e-9.speed
run ExchangeBogoSort go 28.numbers, 1e-9.speed
// The meh ones
run MedianQuickBogoSort with 12.numbers and 1e-9.speed
run QuickBogoSort with 9.numbers and 1e-9.speed
run MergeBogoSort with 9.numbers and 1e-9.speed
run SmartGuessSort with 8.numbers and 1e-9.speed
run MedianQuickBogoSort go 12.numbers, 1e-9.speed
run QuickBogoSort go 9.numbers, 1e-9.speed
run MergeBogoSort go 9.numbers, 1e-9.speed
run SmartGuessSort go 8.numbers, 1e-9.speed
// The scary ones
run BozoSort with 7.numbers and 1e-9.speed
run DeterministicBogoSort with 7.numbers and 1e-9.speed
run SmartBogoBogoSort with 6.numbers and 1e-9.speed
run BogoSort with 6.numbers and 1e-9.speed
run OptimizedGuessSort with 5.numbers and 1e-9.speed
run RandomGuessSort with 5.numbers and 1e-9.speed
run GuessSort with 4.numbers and 1e-9.speed
run BozoSort go 7.numbers, 1e-9.speed
run DeterministicBogoSort go 7.numbers, 1e-9.speed
run SmartBogoBogoSort go 6.numbers, 1e-9.speed
run BogoSort go 6.numbers, 1e-9.speed
run OptimizedGuessSort go 5.numbers, 1e-9.speed
run RandomGuessSort go 5.numbers, 1e-9.speed
run GuessSort go 4.numbers, 1e-9.speed
// aaaaaa
run BogoBogoSort with 4.numbers and 1e-9.speed
run BogoBogoSort go 4.numbers, 1e-9.speed
arrayv.sounds.softerSounds = oldSofterSounds
}
Loading

0 comments on commit b4aa443

Please sign in to comment.