| 186 | * 'to', index of the last element in the range to sort. |
| 187 | */ |
| 188 | template <class Data, class Metadata> void quickSort(std::vector<Data>& data, std::vector<Metadata>& metadata, int (*sortFunction) (Data&, Data&), const unsigned int from, const unsigned int to) |
| 189 | { |
| 190 | if (isSorted(data, sortFunction, from, to)) |
| 191 | return; |
| 192 | |
| 193 | unsigned int pivotIndex = choosePivot(data, sortFunction, from, to); |
| 194 | unsigned int newPivotIndex = partition(data, metadata, sortFunction, from, to, pivotIndex); |
| 195 | if (newPivotIndex > 0) |
| 196 | quickSort(data, metadata, sortFunction, from, newPivotIndex - 1); |
| 197 | if (newPivotIndex < to) |
| 198 | quickSort(data, metadata, sortFunction, newPivotIndex + 1, to); |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | * Prompts the user for a file to load. |
no test coverage detected