Function reform::sort::split_merge [−][src]
pub fn split_merge<T: Default, F1, F2>(
terms: &mut [T],
cmp: &F1,
merger: &F2
) -> Vec<usize> where
F1: Fn(&T, &T) -> Ordering,
F2: Fn(&mut T, &mut T) -> bool,
Sorts a vector of T
according to cmp
, adds
equal elements according to merger
, and returns an index map of
the (merged) elements in the proper
order. We allocate the necessary vectors once and use a separate
recursive routine after that. Reading the output properly is done with
let row = sort::split_merge(&mut terms, &cmp, &merger); let mut out = vec![]; for i in 0..row.len() { out.push(terms[row[i]].clone()); }