fn lomuto_partition<T: std::cmp::PartialOrd>(elements: &mut [T]) -> usize
{
    let mut i: usize = 0;
    let size: usize = elements.len();
    let mut j : usize = 0;

    if elements.is_empty()  { // bounds 1
        return 0;
    }

    while i < size-1 { // bounds 3
        i += 1;
        if elements[i] <= elements[0] { // bounds 4
            j += 1;
            elements.swap(i, j);
        }
    }

    elements.swap(0, j);
    j
}
///
/// Use the algorithm that has fewer boundary conditions to worry about
Use the algorithm that has fewer boundary conditions to worry about
Use the algorithm that has fewer boundary conditions to worry about
fn lomuto_partition<T: std::cmp::PartialOrd>(elements: &mut [T]) -> usize
{
    let mut i: usize = 0;
    let size: usize = elements.len();
    let mut j : usize = 0;
    if elements.is_empty()  { // bounds 1
        return 0;
    }
    while i < size-1 { // bounds 3
        i += 1;
        if elements[i] <= elements[0] { // bounds 4
            j += 1;
            elements.swap(i, j);
        }
    }
    elements.swap(0, j);
    j
}
fn lomuto_partition < T : std :: cmp :: PartialOrd > ( elements : & mut [ T ] ) -> usize { let mut i : usize = 0 ; let size : usize = elements . len ( ) ; let mut j : usize = 0 ; if elements . is_empty ( ) { // bounds 1 return 0 ; } while i < size - 1 { // bounds 3 i += 1 ; if elements [ i ] <= elements [ 0 ] { // bounds 4 j += 1 ; elements . swap ( i , j ) ; } } elements . swap ( 0 , j ) ; j }
Use the algorithm that has fewer boundary conditions to worry about
Use the algorithm that has fewer boundary conditions to worry about
elements
&mut [T]
elements
&mut [T]