Function rudac::algo::transform::partition[][src]

pub fn partition<T: Ord>(slice: &mut [T], pivot_index: usize) -> usize
Expand description

Partitions the slice around the element at pivot_index. Returns index of pivot after partitioning

Arguments

  • slice: slice of data to be partitioned
  • pivot_index: index of the pivot. slice will be partitioned around item at this index

Examples

use rudac::algo::transform::partition;
 
let mut vec = vec![10, 6, 1, 4, 2, 3, 7, 9, 8, 5];
 
partition(&mut vec, 3);
 
//                          pivot
//                            '
assert_eq!(vec, vec![1, 2, 3, 4, 6, 10, 7, 9, 8, 5]);