Function comlib_math::next_permutation [−][src]
pub fn next_permutation<T>(data: &mut [T]) -> bool where
T: Ord, Expand description
Computes lexicographically next smallest permutation.
This is done by finding a the longest decreasing suffix of the given slice, and replacing the preceding element by the next smallest element of the suffix.
Examples
All permutations of a list can be iterated as follows:
let mut list = [1, 3, 2, 4, 2];
list.sort();
loop {
// Do something with list
if !next_permutation(&mut list) {
break;
}
}