From 0588341ff38a48f0e8671dbab95fd0ca7e45973d Mon Sep 17 00:00:00 2001 From: wakfi <55608093+wakfi@users.noreply.github.com> Date: Mon, 7 Sep 2020 19:09:07 -0700 Subject: [PATCH] Remove ShatterSort, SimpleShatterSort, and ShatterSorting template --- src/sorts/ShatterSort.java | 55 -------------- src/sorts/SimpleShatterSort.java | 55 -------------- src/templates/ShatterSorting.java | 100 -------------------------- src/threads/RunDistributionSorts.java | 6 -- 4 files changed, 216 deletions(-) delete mode 100644 src/sorts/ShatterSort.java delete mode 100644 src/sorts/SimpleShatterSort.java delete mode 100644 src/templates/ShatterSorting.java diff --git a/src/sorts/ShatterSort.java b/src/sorts/ShatterSort.java deleted file mode 100644 index c1314f53..00000000 --- a/src/sorts/ShatterSort.java +++ /dev/null @@ -1,55 +0,0 @@ -package sorts; - -import templates.ShatterSorting; -import utils.Delays; -import utils.Highlights; -import utils.Reads; -import utils.Writes; - -/* - * -MIT License - -Copyright (c) 2019 w0rthy - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - * - */ - -final public class ShatterSort extends ShatterSorting { - public ShatterSort(Delays delayOps, Highlights markOps, Reads readOps, Writes writeOps) { - super(delayOps, markOps, readOps, writeOps); - - this.setSortPromptID("Shatter"); - this.setRunAllID("Shatter Sort"); - this.setReportSortID("Shatter Sort"); - this.setCategory("Distributive Sorts"); - this.isComparisonBased(false); - this.isBucketSort(true); - this.isRadixSort(false); - this.isUnreasonablySlow(false); - this.setUnreasonableLimit(0); - this.isBogoSort(false); - } - - @Override - public void runSort(int[] array, int length, int bucketCount) { - this.shatterSort(array, length, bucketCount); - } -} \ No newline at end of file diff --git a/src/sorts/SimpleShatterSort.java b/src/sorts/SimpleShatterSort.java deleted file mode 100644 index 5b4e33c4..00000000 --- a/src/sorts/SimpleShatterSort.java +++ /dev/null @@ -1,55 +0,0 @@ -package sorts; - -import templates.ShatterSorting; -import utils.Delays; -import utils.Highlights; -import utils.Reads; -import utils.Writes; - -/* - * -MIT License - -Copyright (c) 2019 w0rthy - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - * - */ - -final public class SimpleShatterSort extends ShatterSorting { - public SimpleShatterSort(Delays delayOps, Highlights markOps, Reads readOps, Writes writeOps) { - super(delayOps, markOps, readOps, writeOps); - - this.setSortPromptID("Simple Shatter"); - this.setRunAllID("Simple Shatter Sort"); - this.setReportSortID("Simple Shatter Sort"); - this.setCategory("Distributive Sorts"); - this.isComparisonBased(false); - this.isBucketSort(true); - this.isRadixSort(false); - this.isUnreasonablySlow(false); - this.setUnreasonableLimit(0); - this.isBogoSort(false); - } - - @Override - public void runSort(int[] array, int length, int bucketCount) { - this.simpleShatterSort(array, length, bucketCount, (int) (Math.log(length) / Math.log(2)) / 2); - } -} \ No newline at end of file diff --git a/src/templates/ShatterSorting.java b/src/templates/ShatterSorting.java deleted file mode 100644 index e40115f6..00000000 --- a/src/templates/ShatterSorting.java +++ /dev/null @@ -1,100 +0,0 @@ -package templates; - -import java.util.ArrayList; - -import utils.Delays; -import utils.Highlights; -import utils.Reads; -import utils.Writes; - -/* - * -MIT License - -Copyright (c) 2019 w0rthy - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - * - */ - -public abstract class ShatterSorting extends Sort { - protected ShatterSorting(Delays delayOps, Highlights markOps, Reads readOps, Writes writeOps) { - super(delayOps, markOps, readOps, writeOps); - } - - private void shatterPartition(int[] array, int length, int num) { - int shatters = (int) Math.ceil(length / (double) num); - - @SuppressWarnings("unchecked") - ArrayList[] registers = new ArrayList[shatters]; - - for(int i = 0; i < shatters; i++) { - registers[i] = new ArrayList<>(); - } - - for(int i = 0; i < length; i++){ - registers[array[i] / num].add(array[i]); - Highlights.markArray(1, i); - - Writes.mockWrite(length, array[i] / num, array[i], 0.5); - } - - Writes.transcribe(array, registers, 0, true, false); - } - - protected void shatterSort(int[] array, int length, int num) { - int shatters = (int) Math.ceil(length / (double) num); - - shatterPartition(array, length, num); - - int[] tmp = new int[num]; - for(int i = 0; i < shatters; i++) { - for(int j = 0; j < num; j++) { - if(i * num + j >= length) - Writes.write(tmp, j, -1, 0.5, false, true); - else - Writes.write(tmp, j, array[i * num + j], 0.5, false, true); - - Highlights.markArray(2, i * num + j); - } - - Highlights.clearMark(2); - - for(int j = 0; j < tmp.length; j++) { - int tmpj = tmp[j]; - - if(i * num + (tmpj % num) >= length || tmpj == -1) { - break; - } - - Writes.write(array, i * num + (tmpj % num), tmpj, 1, false, false); - Highlights.markArray(1, i * num + (tmpj % num)); - } - - Highlights.clearMark(1); - } - } - - protected void simpleShatterSort(int[] array, int length, int num, int rate) { - for(int i = num; i > 1; i = i / rate) { - shatterPartition(array, length, i); - } - shatterPartition(array, length, 1); - } -} \ No newline at end of file diff --git a/src/threads/RunDistributionSorts.java b/src/threads/RunDistributionSorts.java index c8279716..e98d0706 100644 --- a/src/threads/RunDistributionSorts.java +++ b/src/threads/RunDistributionSorts.java @@ -11,8 +11,6 @@ import sorts.MSDRadixSort; import sorts.PigeonholeSort; import sorts.RecursiveBinaryQuickSort; -import sorts.ShatterSort; -import sorts.SimpleShatterSort; import sorts.TimeSort; import templates.JErrorPane; import templates.MultipleSortThread; @@ -74,8 +72,6 @@ public RunDistributionSorts(ArrayVisualizer ArrayVisualizer) { FlashSort = new FlashSort(Delays, Highlights, Reads, Writes); BinaryQuickSort = new BinaryQuickSort(Delays, Highlights, Reads, Writes); RecursiveBinaryQuickSort = new RecursiveBinaryQuickSort(Delays, Highlights, Reads, Writes); - ShatterSort = new ShatterSort(Delays, Highlights, Reads, Writes); - SimpleShatterSort = new SimpleShatterSort(Delays, Highlights, Reads, Writes); TimeSort = new TimeSort(Delays, Highlights, Reads, Writes); } @@ -93,8 +89,6 @@ protected synchronized void executeSortList(int[] array) throws Exception { RunDistributionSorts.this.runIndividualSort(FlashSort, 0, array, 2048, 1); RunDistributionSorts.this.runIndividualSort(BinaryQuickSort, 0, array, 2048, 1); RunDistributionSorts.this.runIndividualSort(RecursiveBinaryQuickSort, 0, array, 2048, 1); - RunDistributionSorts.this.runIndividualSort(ShatterSort, 128, array, 2048, 1); - RunDistributionSorts.this.runIndividualSort(SimpleShatterSort, 128, array, 2048, 1); RunDistributionSorts.this.runIndividualSort(TimeSort, 10, array, 2048, 1); }