x = x + y; y = x - y; x = x - y;
static void sort (int [] a);Reicht das:
public void testSort () {
int [] a = { 4,2,3,1,5 };
sort (a);
assertMonotonSteigend (a);
}
swap_if_gt benutzt
(d. h. keine weiteren Elementvergleiche
oder Zuweisungen ausführt)
static void swap (int [] a, int i, int j) {
int h = a[i]; a[i] = a[j]; a[j] = h;
}
static void swap_if_gt
(int [] a, int i, int j) {
if (a[i] > a[j]) { swap (a, i, j); }
}