I have the following code:
我有以下代码:
int partition(void* arr, int start, int end, bool(*cmp_f)(void*, void*),
void(*swap_f)(void*, void*)) {
// Point *pivot = &pts[end];
int partition_index = start;
for (int i = start; i < end; i++) {
if (cmp_f(&arr[i], &arr[end])) {// <---------- Here
swap_f(&arr[i], &arr[partition_index]);// <---------- Here
partition_index++;
}
}
swap_f(&arr[end], &arr[partition_index]);// <---------- Here
return partition_index;
}
//------------------------------------------------------------------------------
void quick_sort(Point* pts, int start, int end, bool(*cmp_f)(void*, void*),
void(*swap_f)(void*, void*)) {
if (start < end) {//As long start is less than end we should arrange
int pivot = partition(pts, start, end, cmp_f, swap_f);
quick_sort(pts, start, pivot - 1, cmp_f, swap_f);
quick_sort(pts, pivot + 1, end, cmp_f, swap_f);
}
}
//------------------------------------------------------------------------------
int part