Description
prev_permutation() computes the previous permutation for a sequence of elements. Permutations are produced in lexicographical order, which can be overridden by a user-defined ordering function. false is returned when there are no more permutations.
Declaration
template <class Bi> bool prev_permutation(Bi, Bi); template <class Bi, class Cmp> bool prev_permutation(Bi, Bi, Cmp);
Concept
The program sets up a vector of integers, and then displays each permutation of the elements, starting with the last one. A user-supplied ordering function is used to compare elements based on their absolute magnitude. Output of the program is:
10 -5 1 10 1 -5 -5 10 1 -5 1 10 1 10 -5 1 -5 10
Supported
Supported
Supported