Sorting.cpp
/**
 * Selection sort algorithm
 * @param arr The PagedArray pointer to be sorted
 * @param n The number of elements in the array
 */
Selection sort algorithm
@param arr The PagedArray pointer to be sorted
@param n The number of elements in the array
Selection sort algorithm @param arr The PagedArray pointer to be sorted @param n The number of elements in the array
void Sorting::selectionSort(PagedArray *arr, int n) {
    int i, j, minIndex, tmp;
    for (i = 0; i < n - 1; i++) {
        minIndex = i;
        for (j = i + 1; j < n; j++)
            if (arr->operator[](j) < arr->operator[](minIndex))
                minIndex = j;
        if (minIndex != i) {
            tmp = arr->operator[](i);
            arr->operator[](i) = arr->operator[](minIndex);
            arr->operator[](minIndex) = tmp;
        }
    }
}
void Sorting :: selectionSort ( PagedArray * arr , int n ) { int i , j , minIndex , tmp ; for ( i = 0 ; i < n - 1 ; i ++ ) { minIndex = i ; for ( j = i + 1 ; j < n ; j ++ ) if ( arr -> operator [ ] ( j ) < arr -> operator [ ] ( minIndex ) ) minIndex = j ; if ( minIndex != i ) { tmp = arr -> operator [ ] ( i ) ; arr -> operator [ ] ( i ) = arr -> operator [ ] ( minIndex ) ; arr -> operator [ ] ( minIndex ) = tmp ; } } }
Selection sort algorithm
 @param arr The PagedArray pointer to be sorted
 @param n The number of elements in the array
Selection sort algorithm @param arr The PagedArray pointer to be sorted @param n The number of elements in the array