From Jason Turner

[alg.permutation.generators]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpaxsevtn0/{from.md → to.md} +54 -16
tmp/tmpaxsevtn0/{from.md → to.md} RENAMED
@@ -1,50 +1,88 @@
1
  ### Permutation generators <a id="alg.permutation.generators">[[alg.permutation.generators]]</a>
2
 
3
  ``` cpp
4
  template<class BidirectionalIterator>
5
- bool next_permutation(BidirectionalIterator first,
6
  BidirectionalIterator last);
7
 
8
  template<class BidirectionalIterator, class Compare>
9
- bool next_permutation(BidirectionalIterator first,
10
  BidirectionalIterator last, Compare comp);
 
 
 
 
 
 
 
 
 
 
 
11
  ```
12
 
13
- *Requires:* `BidirectionalIterator` shall satisfy the requirements of
14
- `ValueSwappable` ([[swappable.requirements]]).
 
 
 
 
15
 
16
  *Effects:* Takes a sequence defined by the range \[`first`, `last`) and
17
  transforms it into the next permutation. The next permutation is found
18
  by assuming that the set of all permutations is lexicographically sorted
19
- with respect to `operator<` or `comp`.
 
 
20
 
21
- *Returns:* `true` if such a permutation exists. Otherwise, it transforms
22
- the sequence into the smallest permutation, that is, the ascendingly
23
- sorted one, and returns `false`.
 
 
24
 
25
  *Complexity:* At most `(last - first) / 2` swaps.
26
 
27
  ``` cpp
28
  template<class BidirectionalIterator>
29
- bool prev_permutation(BidirectionalIterator first,
30
  BidirectionalIterator last);
31
 
32
  template<class BidirectionalIterator, class Compare>
33
- bool prev_permutation(BidirectionalIterator first,
34
  BidirectionalIterator last, Compare comp);
 
 
 
 
 
 
 
 
 
 
 
35
  ```
36
 
37
- *Requires:* `BidirectionalIterator` shall satisfy the requirements of
38
- `ValueSwappable` ([[swappable.requirements]]).
 
 
 
 
39
 
40
  *Effects:* Takes a sequence defined by the range \[`first`, `last`) and
41
  transforms it into the previous permutation. The previous permutation is
42
  found by assuming that the set of all permutations is lexicographically
43
- sorted with respect to `operator<` or `comp`.
 
 
44
 
45
- *Returns:* `true` if such a permutation exists. Otherwise, it transforms
46
- the sequence into the largest permutation, that is, the descendingly
47
- sorted one, and returns `false`.
 
 
48
 
49
  *Complexity:* At most `(last - first) / 2` swaps.
50
 
 
1
  ### Permutation generators <a id="alg.permutation.generators">[[alg.permutation.generators]]</a>
2
 
3
  ``` cpp
4
  template<class BidirectionalIterator>
5
+ constexpr bool next_permutation(BidirectionalIterator first,
6
  BidirectionalIterator last);
7
 
8
  template<class BidirectionalIterator, class Compare>
9
+ constexpr bool next_permutation(BidirectionalIterator first,
10
  BidirectionalIterator last, Compare comp);
11
+
12
+ template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
13
+ class Proj = identity>
14
+ requires sortable<I, Comp, Proj>
15
+ constexpr ranges::next_permutation_result<I>
16
+ ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {});
17
+ template<bidirectional_range R, class Comp = ranges::less,
18
+ class Proj = identity>
19
+ requires sortable<iterator_t<R>, Comp, Proj>
20
+ constexpr ranges::next_permutation_result<borrowed_iterator_t<R>>
21
+ ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {});
22
  ```
23
 
24
+ Let `comp` be `less{}` and `proj` be `identity{}` for overloads with no
25
+ parameters by those names.
26
+
27
+ *Preconditions:* For the overloads in namespace `std`,
28
+ `BidirectionalIterator` meets the *Cpp17ValueSwappable*
29
+ requirements [[swappable.requirements]].
30
 
31
  *Effects:* Takes a sequence defined by the range \[`first`, `last`) and
32
  transforms it into the next permutation. The next permutation is found
33
  by assuming that the set of all permutations is lexicographically sorted
34
+ with respect to `comp` and `proj`. If no such permutation exists,
35
+ transforms the sequence into the first permutation; that is, the
36
+ ascendingly-sorted one.
37
 
38
+ *Returns:* Let `B` be `true` if a next permutation was found and
39
+ otherwise `false`. Returns:
40
+
41
+ - `B` for the overloads in namespace `std`.
42
+ - `{ last, B }` for the overloads in namespace `ranges`.
43
 
44
  *Complexity:* At most `(last - first) / 2` swaps.
45
 
46
  ``` cpp
47
  template<class BidirectionalIterator>
48
+ constexpr bool prev_permutation(BidirectionalIterator first,
49
  BidirectionalIterator last);
50
 
51
  template<class BidirectionalIterator, class Compare>
52
+ constexpr bool prev_permutation(BidirectionalIterator first,
53
  BidirectionalIterator last, Compare comp);
54
+
55
+ template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
56
+ class Proj = identity>
57
+ requires sortable<I, Comp, Proj>
58
+ constexpr ranges::prev_permutation_result<I>
59
+ ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {});
60
+ template<bidirectional_range R, class Comp = ranges::less,
61
+ class Proj = identity>
62
+ requires sortable<iterator_t<R>, Comp, Proj>
63
+ constexpr ranges::prev_permutation_result<borrowed_iterator_t<R>>
64
+ ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {});
65
  ```
66
 
67
+ Let `comp` be `less{}` and `proj` be `identity{}` for overloads with no
68
+ parameters by those names.
69
+
70
+ *Preconditions:* For the overloads in namespace `std`,
71
+ `BidirectionalIterator` meets the *Cpp17ValueSwappable*
72
+ requirements [[swappable.requirements]].
73
 
74
  *Effects:* Takes a sequence defined by the range \[`first`, `last`) and
75
  transforms it into the previous permutation. The previous permutation is
76
  found by assuming that the set of all permutations is lexicographically
77
+ sorted with respect to `comp` and `proj`. If no such permutation exists,
78
+ transforms the sequence into the last permutation; that is, the
79
+ descendingly-sorted one.
80
 
81
+ *Returns:* Let `B` be `true` if a previous permutation was found and
82
+ otherwise `false`. Returns:
83
+
84
+ - `B` for the overloads in namespace `std`.
85
+ - `{ last, B }` for the overloads in namespace `ranges`.
86
 
87
  *Complexity:* At most `(last - first) / 2` swaps.
88