| 800 | } |
| 801 | |
| 802 | private <E extends T> int partition(E[] values, int left, int right, int pivotIndex) { |
| 803 | E pivotValue = values[pivotIndex]; |
| 804 | values[pivotIndex] = values[right]; |
| 805 | values[right] = pivotValue; |
| 806 | int storeIndex = left; |
| 807 | for (int i = left; i < right; i++) { |
| 808 | if (compare(values[i], pivotValue) < 0) { |
| 809 | ObjectArrays.swap(values, storeIndex, i); |
| 810 | storeIndex++; |
| 811 | } |
| 812 | } |
| 813 | ObjectArrays.swap(values, right, storeIndex); |
| 814 | return storeIndex; |
| 815 | } |
| 816 | |
| 817 | /** |
| 818 | * Returns the {@code k} greatest elements of the given iterable according to |