2014-05-31|1275阅|作者:空心|举报 摘要:template void Sort::QuickSort(T *array, int left, int right) { if(left < right) { int i = left -1, j = right + 1;
template
void Sort::QuickSort(T *array, int left, int right)
{
if(left < right)
{
int i = left -1, j = right + 1;
T mid = array[(left + right) / 2];
while(true)
{
while(array[++i] < mid);
while(array[--j] > mid);
if(i >= j)
{
break;
}
Swap(array, i, j);
}
QuickSort(array, left, i - 1);
QuickSort(array, j + 1, right);
}
}