C++:"reset"std :: next_permutation()

nas*_*-sh 4 c++ algorithm stl

有没有办法"重置" std::next_permutation()?假设我想多次检查向量的排列.我唯一能找到的就是经历next_permutationprev_permutation另类.

谢谢

Nik*_* B. 8

"重置"将对序列进行排序,例如使用std::sort.请注意,如果要使用枚举所有排列,必须从排序序列开始next_permutation.

此外,一旦再次达到按字典顺序排列的最小排列,std::next_permutation将返回false.