mirror of
https://gitlab.uni-marburg.de/langbeid/powersort.git
synced 2025-01-21 19:50:35 +01:00
FasterFinnSort: change access
This commit is contained in:
parent
42a0c24f67
commit
9a6359d576
@ -81,7 +81,7 @@ public class FasterFinnSort<T> {
|
||||
* 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<T> {
|
||||
* 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<T> {
|
||||
* @param workBase origin of usable space in work array
|
||||
* @param workLen usable size of work array
|
||||
*/
|
||||
private FasterFinnSort(T[] a, Comparator<? super T> c, T[] work, int workBase, int workLen) {
|
||||
FasterFinnSort(T[] a, Comparator<? super T> c, T[] work, int workBase, int workLen) {
|
||||
this.a = a;
|
||||
this.c = c;
|
||||
|
||||
@ -234,7 +234,7 @@ public class FasterFinnSort<T> {
|
||||
* to maintain stack invariant.
|
||||
*/
|
||||
FasterFinnSort<T> 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<T> {
|
||||
* @param c comparator to used for the sort
|
||||
*/
|
||||
@SuppressWarnings("fallthrough")
|
||||
private static <T> void binarySort(T[] a, int lo, int hi, int start,
|
||||
static <T> void binarySort(T[] a, int lo, int hi, int start,
|
||||
Comparator<? super T> c) {
|
||||
assert lo <= start && start <= hi;
|
||||
if (start == lo)
|
||||
@ -350,7 +350,7 @@ public class FasterFinnSort<T> {
|
||||
* @return the length of the run beginning at the specified position in
|
||||
* the specified array
|
||||
*/
|
||||
private static <T> int countRunAndMakeAscending(T[] a, int lo, int hi,
|
||||
static <T> int countRunAndMakeAscending(T[] a, int lo, int hi,
|
||||
Comparator<? super T> c) {
|
||||
assert lo < hi;
|
||||
int runHi = lo + 1;
|
||||
@ -403,7 +403,7 @@ public class FasterFinnSort<T> {
|
||||
* @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<T> {
|
||||
* @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<T> {
|
||||
* 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<T> {
|
||||
}
|
||||
}
|
||||
|
||||
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<T> {
|
||||
* 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])
|
||||
|
Loading…
x
Reference in New Issue
Block a user