/* file QuickSort.h */ // code by bds, 2/00, 9/02 #ifndef __QUICKSORT__ #define __QUICKSORT__ #include #include "iterator_traits" // for braindead CC #include "partition.h" template /* We require that class Iterator has pointer arithmetic operations and that the unknown class pointed to by dereferencing iterators has operator <= defined. */ void quickSort(Iterator b, Iterator e, bool randomized = false) { // The items in locations [b, (b+1) .. e) will be permuted into sorted order. if ((e-b) <= 1) // then zero or one elements -- and that's already sorted. ; else { Iterator p = partition(b, e, randomized); ++p; quickSort(b, p); quickSort(p, e); } } #endif