pub fn next_permutation<T: Ord>(a: &mut [T]) -> bool
Expand description

辞書順で次の順列の生成。

Idea

todo!()

References

Examples

use nekolib::algo::next_permutation;

let mut a = vec![1, 3, 2];
assert!(next_permutation(&mut a));
assert_eq!(a, [2, 1, 3]);

// last one
let mut a = vec![3, 2];
assert!(!next_permutation(&mut a));
assert_eq!(a, [2, 3]);

// empty one
let mut a = Vec::<()>::new();
assert!(!next_permutation(&mut a));

// duplicated one
let mut a = vec![1, 3, 2, 2, 3];
next_permutation(&mut a);
assert_eq!(a, [1, 3, 2, 3, 2]);