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