]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | [/ |
2 | Copyright 2010 Neil Groves | |
3 | Distributed under the Boost Software License, Version 1.0. | |
4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
5 | /] | |
6 | [section:prev_permutation prev_permutation] | |
7 | ||
8 | [heading Prototype] | |
9 | ||
10 | `` | |
11 | template<class BidirectionalRange> | |
12 | bool prev_permutation(BidirectionalRange& rng); | |
13 | ||
14 | template<class BidirectionalRange> | |
15 | bool prev_permutation(const BidirectionalRange& rng); | |
16 | ||
17 | template<class BidirectionalRange, class Compare> | |
18 | bool prev_permutation(BidirectionalRange& rng, Compare pred); | |
19 | ||
20 | template<class BidirectionalRange, class Compare> | |
21 | bool prev_permutation(const BidirectionalRange& rng, Compare pred); | |
22 | `` | |
23 | ||
24 | [heading Description] | |
25 | ||
26 | `prev_permutation` transforms the range of elements `rng` into the lexicographically next smaller permutation of the elements if such a permutation exists. If one does not exist then the range is transformed into the lexicographically largest permutation and `false` is returned. `true` is returned when the next smaller permutation is successfully generated. | |
27 | ||
28 | The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. | |
29 | ||
30 | [heading Definition] | |
31 | ||
32 | Defined in the header file `boost/range/algorithm/permutation.hpp` | |
33 | ||
34 | [heading Requirements] | |
35 | ||
36 | [*For the non-predicate versions:] | |
37 | ||
38 | * `BidirectionalRange` is a model of the __bidirectional_range__ Concept. | |
39 | * `BidirectionalRange` is mutable. | |
40 | * `BidirectionalRange`'s value type is a model of the `LessThanComparableConcept`. | |
41 | * The ordering of objects of type `BidirectionalRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements. | |
42 | ||
43 | [*For the predicate versions:] | |
44 | ||
45 | * `BidirectionalRange` is a model of the __bidirectional_range__ Concept. | |
46 | * `BidirectionalRange` is mutable. | |
47 | * `Compare` is a model of the `StrictWeakOrderingConcept`. | |
48 | * `BidirectionalRange`'s value type is convertible to both of `Compare`'s argument types. | |
49 | ||
50 | [heading Complexity] | |
51 | ||
52 | Linear. At most `distance(rng) / 2` swaps. | |
53 | ||
54 | [endsect] | |
55 | ||
56 |