diff --git a/app/src/main/java/de/uni_marburg/powersort/FinnSort/FinnSort.java b/app/src/main/java/de/uni_marburg/powersort/FinnSort/FinnSort.java index 657e532..598a44c 100644 --- a/app/src/main/java/de/uni_marburg/powersort/FinnSort/FinnSort.java +++ b/app/src/main/java/de/uni_marburg/powersort/FinnSort/FinnSort.java @@ -66,6 +66,25 @@ public class FinnSort { //printList(a, c); } + private static void merge(T[] a, Run r1, Run r2, Comparator 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 int extendRunRight(T[] a, int i, Comparator c) { if (i >= a.length - 1) return i + 1;