Sorting.cpp
/**
 * QuickSort algorithm
 * @param arr The PagedArray pointer
 * @param left Usually 0, the leftmost index
 * @param right The index number of the rightmost element
 */
QuickSort algorithm
@param arr The PagedArray pointer
@param left Usually 0, the leftmost index
@param right The index number of the rightmost element
QuickSort algorithm @param arr The PagedArray pointer @param left Usually 0 the leftmost index @param right The index number of the rightmost element
void Sorting::quickSort(PagedArray *arr, int left, int right) {
    int i = left, j = right;
    int tmp;
    int pivot = arr->operator[]((left + right) / 2);
    while (i <= j) {
        while (arr->operator[](i) < pivot)
            i++;
        while (arr->operator[](j) > pivot)
            j--;
        if (i <= j) {
            tmp = arr->operator[](i);
            arr->operator[](i) = arr->operator[](j);
            arr->operator[](j) = tmp;
            i++;
            j--;
        }
    };
    if (left < j)
        quickSort(arr, left, j);
    if (i < right)
        quickSort(arr, i, right);
}
void Sorting :: quickSort ( PagedArray * arr , int left , int right ) { int i = left , j = right ; int tmp ; int pivot = arr -> operator [ ] ( ( left + right ) / 2 ) ; while ( i <= j ) { while ( arr -> operator [ ] ( i ) < pivot ) i ++ ; while ( arr -> operator [ ] ( j ) > pivot ) j -- ; if ( i <= j ) { tmp = arr -> operator [ ] ( i ) ; arr -> operator [ ] ( i ) = arr -> operator [ ] ( j ) ; arr -> operator [ ] ( j ) = tmp ; i ++ ; j -- ; } } ; if ( left < j ) quickSort ( arr , left , j ) ; if ( i < right ) quickSort ( arr , i , right ) ; }
QuickSort algorithm
 @param arr The PagedArray pointer
 @param left Usually 0, the leftmost index
 @param right The index number of the rightmost element
QuickSort algorithm @param arr The PagedArray pointer @param left Usually 0 the leftmost index @param right The index number of the rightmost element
/* partition */ /* recursion */