diff --git a/app/src/main/java/de/uni_marburg/powersort/FinnSort/FasterFinnSort.java b/app/src/main/java/de/uni_marburg/powersort/FinnSort/FasterFinnSort.java index 650ed97..5e92f96 100644 --- a/app/src/main/java/de/uni_marburg/powersort/FinnSort/FasterFinnSort.java +++ b/app/src/main/java/de/uni_marburg/powersort/FinnSort/FasterFinnSort.java @@ -81,7 +81,7 @@ public class FasterFinnSort { * of the minimum stack length required as a function of the length * of the array being sorted and the minimum merge sequence length. */ - private static final int MIN_MERGE = 32; + static final int MIN_MERGE = 32; /** * The array being sorted. @@ -134,7 +134,7 @@ public class FasterFinnSort { * so we could cut the storage for this, but it's a minor amount, * and keeping all the info explicit simplifies the code. */ - private int stackSize = 0; // Number of pending runs on stack + int stackSize = 0; // Number of pending runs on stack private final int[] runBase; private final int[] runLen; private final int[] runPower; @@ -148,7 +148,7 @@ public class FasterFinnSort { * @param workBase origin of usable space in work array * @param workLen usable size of work array */ - private FasterFinnSort(T[] a, Comparator c, T[] work, int workBase, int workLen) { + FasterFinnSort(T[] a, Comparator c, T[] work, int workBase, int workLen) { this.a = a; this.c = c; @@ -234,7 +234,7 @@ public class FasterFinnSort { * to maintain stack invariant. */ FasterFinnSort ts = new FasterFinnSort<>(a, c, work, workBase, workLen); - int minRun = minRunLength(nRemaining); + int minRun = ts.minRunLength(nRemaining); do { // Identify next run int runLen = countRunAndMakeAscending(a, lo, hi, c); @@ -280,7 +280,7 @@ public class FasterFinnSort { * @param c comparator to used for the sort */ @SuppressWarnings("fallthrough") - private static void binarySort(T[] a, int lo, int hi, int start, + static void binarySort(T[] a, int lo, int hi, int start, Comparator c) { assert lo <= start && start <= hi; if (start == lo) @@ -350,7 +350,7 @@ public class FasterFinnSort { * @return the length of the run beginning at the specified position in * the specified array */ - private static int countRunAndMakeAscending(T[] a, int lo, int hi, + static int countRunAndMakeAscending(T[] a, int lo, int hi, Comparator c) { assert lo < hi; int runHi = lo + 1; @@ -403,7 +403,7 @@ public class FasterFinnSort { * @param n the length of the array to be sorted * @return the length of the minimum run to be merged */ - private static int minRunLength(int n) { + int minRunLength(int n) { assert n >= 0; int r = 0; // Becomes 1 if any 1 bits are shifted off while (n >= MIN_MERGE) { @@ -419,7 +419,7 @@ public class FasterFinnSort { * @param runBase index of the first element in the run * @param runLen the number of elements in the run */ - private void pushRun(int runBase, int runLen, int rangeSize) { + void pushRun(int runBase, int runLen, int rangeSize) { this.runBase[stackSize] = runBase; this.runLen[stackSize] = runLen; this.runPower[stackSize] = power(stackSize, rangeSize); @@ -442,7 +442,7 @@ public class FasterFinnSort { * the analysis in "On the Worst-Case Complexity of TimSort" by * Nicolas Auger, Vincent Jug, Cyril Nicaud, and Carine Pivoteau. */ - private void mergeCollapse() { + void mergeCollapse() { while (stackSize > 1) { int n = stackSize - 2; if (n > 0 && runPower[n + 1] < runPower[n]) { @@ -453,7 +453,7 @@ public class FasterFinnSort { } } - private int power(int stackSize, int rangeSize) { + int power(int stackSize, int rangeSize) { if (stackSize == 0) return 0; @@ -500,7 +500,7 @@ public class FasterFinnSort { * Merges all runs on the stack until only one remains. This method is * called once, to complete the sort. */ - private void mergeForceCollapse() { + void mergeForceCollapse() { while (stackSize > 1) { int n = stackSize - 2; if (n > 0 && runLen[n - 1] < runLen[n + 1])