Expand description
Generate permutations iteratively without recursion.
Permutations.of(n) function generates an iterator instance for permutations of 0..n.
Permutations.next() uses Steinhaus-Johnson-Trotter algorithm with Even’s modification to generate the next permutation
in $O(n)$ time.
Each iterator is one-way. You need to construct a new one for iterating again.
Structs§
- Permutations
- Implements
Iterator.
Functions§
- inverse_
perm - Generates the inverse permutation. Has $O(n)$ time complexity.