Method
partition
(
int[] keys,
Map<Integer, Integer> map,
int left,
int right,
int pivot
)
Source from the content-addressed store, hash-verified
| 65 | } |
| 66 | |
| 67 | private int partition( |
| 68 | int[] keys, |
| 69 | Map<Integer, Integer> map, |
| 70 | int left, |
| 71 | int right, |
| 72 | int pivot |
| 73 | ) { |
| 74 | int pivotValue = map.get(keys[pivot]); |
| 75 | swap(keys, pivot, right); |
| 76 | int index = left; |
| 77 | |
| 78 | for (int i = left; i <= right; i++) if (map.get(keys[i]) < pivotValue) { |
| 79 | swap(keys, i, index); |
| 80 | index++; |
| 81 | } |
| 82 | swap(keys, right, index); |
| 83 | return index; |
| 84 | } |
| 85 | |
| 86 | private void swap(int[] array, int i1, int i2) { |
| 87 | int temp = array[i1]; |
Tested by
no test coverage detected