mirror of
https://gitlab.uni-marburg.de/langbeid/powersort.git
synced 2025-01-21 19:50:35 +01:00
Faster Merging of FinnSort
This commit is contained in:
parent
a2dd6ac325
commit
3974f575a9
@ -66,6 +66,25 @@ public class FinnSort {
|
||||
//printList(a, c);
|
||||
}
|
||||
|
||||
private static <T> void merge(T[] a, Run r1, Run r2, Comparator<? super T> c) {
|
||||
T[] left = java.util.Arrays.copyOfRange(a, r1.start, r1.end);
|
||||
int l = 0;
|
||||
int r = r2.start;
|
||||
int k = r1.start;
|
||||
|
||||
while (l < left.length && r < r2.end) {
|
||||
if (c.compare(left[l], a[r]) <= 0) {
|
||||
a[k++] = left[l++];
|
||||
} else {
|
||||
a[k++] = a[r++];
|
||||
}
|
||||
}
|
||||
|
||||
while (l < left.length) {
|
||||
a[k++] = left[l++];
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> int extendRunRight(T[] a, int i, Comparator<? super T> c) {
|
||||
if (i >= a.length - 1)
|
||||
return i + 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user