mirror of
https://gitlab.uni-marburg.de/langbeid/powersort.git
synced 2025-01-21 19:50:35 +01:00
fix: QuickSort mergeRuns
This commit is contained in:
parent
4528a544b7
commit
48a2db7bee
@ -818,13 +818,13 @@ public final class DualPivotQuicksort {
|
||||
a1 = mergeRuns(a, b, offset, -aim, run, lo, mi);
|
||||
a2 = mergeRuns(a, b, offset, 0, run, mi, hi);
|
||||
|
||||
Object[] dst = NaturalOrder.INSTANCE.compare(a1, a) == 0 ? b : a;
|
||||
Object[] dst = a1 == a ? b : a;
|
||||
|
||||
int k = NaturalOrder.INSTANCE.compare(a1 , a)==0 ? run[lo] - offset : run[lo];
|
||||
int lo1 = NaturalOrder.INSTANCE.compare(a1 , b)==0 ? run[lo] - offset : run[lo];
|
||||
int hi1 = NaturalOrder.INSTANCE.compare(a1 , b)==0 ? run[mi] - offset : run[mi];
|
||||
int lo2 = NaturalOrder.INSTANCE.compare(a2 , b)==0 ? run[mi] - offset : run[mi];
|
||||
int hi2 = NaturalOrder.INSTANCE.compare(a2 , b)==0 ? run[hi] - offset : run[hi];
|
||||
int k = a1 == a ? run[lo] - offset : run[lo];
|
||||
int lo1 = a1 == b ? run[lo] - offset : run[lo];
|
||||
int hi1 = a1 == b ? run[mi] - offset : run[mi];
|
||||
int lo2 = a2 == b ? run[mi] - offset : run[mi];
|
||||
int hi2 = a2 == b ? run[hi] - offset : run[hi];
|
||||
|
||||
mergeParts(dst, k, a1, lo1, hi1, a2, lo2, hi2);
|
||||
return dst;
|
||||
|
@ -32,6 +32,7 @@ public abstract class AbstractSortTest {
|
||||
"3,7,-3",
|
||||
"10,10,-5",
|
||||
"17,17,-17",
|
||||
"2,128,-64", // Large runs to trigger function `mergeRuns` of DualPivotQuicksort
|
||||
})
|
||||
void test2(int numOfRuns, int runLength, int decreaseBetweenRuns) {
|
||||
Integer[] array = AscendingRuns.newAscendingRuns(numOfRuns, runLength, decreaseBetweenRuns).getCopy();
|
||||
|
Loading…
x
Reference in New Issue
Block a user