equal
deleted
inserted
replaced
272 /* |
272 /* |
273 * The invariants still hold: pivot >= all in [lo, left) and |
273 * The invariants still hold: pivot >= all in [lo, left) and |
274 * pivot < all in [left, start), so pivot belongs at left. Note |
274 * pivot < all in [left, start), so pivot belongs at left. Note |
275 * that if there are elements equal to pivot, left points to the |
275 * that if there are elements equal to pivot, left points to the |
276 * first slot after them -- that's why this sort is stable. |
276 * first slot after them -- that's why this sort is stable. |
277 * Slide elements over to make room to make room for pivot. |
277 * Slide elements over to make room for pivot. |
278 */ |
278 */ |
279 int n = start - left; // The number of elements to move |
279 int n = start - left; // The number of elements to move |
280 // Switch is just an optimization for arraycopy in default case |
280 // Switch is just an optimization for arraycopy in default case |
281 switch (n) { |
281 switch (n) { |
282 case 2: a[left + 2] = a[left + 1]; |
282 case 2: a[left + 2] = a[left + 1]; |