49 template <
class T,
class CMPR>
50 void partition(T *data,
size_t n,
size_t &pivot, CMPR &cmp)
60 ptpart = data + (rand() % n);
62 ptpart = data + (random() % n);
70 for (p = data - 1, q = data + n;;) {
74 }
while (cmp.compare(*q, tpart) > 0);
77 }
while (cmp.compare(*p, tpart) < 0);
92 template <
class T,
class CMPR>
97 for (p = data + 1; p < data + n; p++) {
98 for (q = p - 1, test = *p; (cmp.compare(*q, test) > 0); q--) {
110 template <
class T,
class CMPR>
111 void quicksort(T *data,
size_t n, CMPR &cmp,
size_t min_len = 20)
121 quicksort(data, pivot + 1, cmp, min_len);
122 quicksort(data + pivot + 1, n - pivot - 1, cmp, min_len);
void partition(T *data, size_t n, size_t &pivot, CMPR &cmp)
void insertionsort(T *data, size_t n, CMPR &cmp)
void quicksort(T *data, size_t n, CMPR &cmp, size_t min_len=20)