pub trait NextPermutation {
    // Required method
    fn next_permutation(&mut self) -> bool;
}
Expand description

next permutation です。

実装の参考資料

Required Methods§

source

fn next_permutation(&mut self) -> bool

Implementations on Foreign Types§

source§

impl<T: Ord> NextPermutation for [T]

source§

fn next_permutation(&mut self) -> bool

数列を辞書順でひとつ進めます。進めなかったら false を返します。

Examples
use next_permutation::NextPermutation;
let mut a = vec![1, 2, 3];
a.next_permutation();
assert_eq!(a, vec![1, 3, 2]);
a.next_permutation();
assert_eq!(a, vec![2, 1, 3]);
let mut a = vec![3, 2, 1];
assert!(!a.next_permutation());

Implementors§