MCPcopy Create free account
hub / github.com/Stewmath/GameYob / quickSort

Function quickSort

arm9/source/filechooser.cpp:188–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186 * 'to', index of the last element in the range to sort.
187 */
188template <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.

Callers 1

startFileChooserFunction · 0.85

Calls 3

isSortedFunction · 0.85
choosePivotFunction · 0.85
partitionFunction · 0.85

Tested by

no test coverage detected