Method
merge
(Comparable[] a, Comparable[] aux, int lo, int mid, int hi)
Source from the content-addressed store, hash-verified
| 15 | } |
| 16 | |
| 17 | private static void merge(Comparable[] a, Comparable[] aux, int lo, int mid, int hi) { |
| 18 | for (int k = lo; k <= hi; k++) { |
| 19 | aux[k] = a[k]; |
| 20 | } |
| 21 | int i = lo, j = mid + 1; |
| 22 | for (int k = lo; k <= hi; k++) { |
| 23 | if (i > mid) |
| 24 | a[k] = aux[j++]; |
| 25 | else if (j > hi) |
| 26 | a[k] = aux[i++]; |
| 27 | else if (less(aux[j], aux[i])) |
| 28 | a[k] = aux[j++]; |
| 29 | else |
| 30 | a[k] = aux[i++]; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | private static boolean less(Comparable v, Comparable w) { |
| 35 | return v.compareTo(w) < 0; |
Tested by
no test coverage detected