From Jason Turner

[list.ops]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp4yyezslk/{from.md → to.md} +40 -40
tmp/tmp4yyezslk/{from.md → to.md} RENAMED
@@ -1,13 +1,16 @@
1
  #### Operations <a id="list.ops">[[list.ops]]</a>
2
 
3
  Since lists allow fast insertion and erasing from the middle of a list,
4
- certain operations are provided specifically for them.[^3] In this
5
- subclause, arguments for a template parameter named `Predicate` or
6
- `BinaryPredicate` shall meet the corresponding requirements in
7
- [[algorithms.requirements]]. For `merge` and `sort`, the definitions and
8
- requirements in [[alg.sorting]] apply.
 
 
 
9
 
10
  `list` provides three splice operations that destructively move elements
11
  from one list to another. The behavior of splice operations is undefined
12
  if `get_allocator() !=
13
  x.get_allocator()`.
@@ -82,67 +85,64 @@ the erased elements.
82
  *Returns:* The number of elements erased.
83
 
84
  *Throws:* Nothing unless an exception is thrown by `*i == value` or
85
  `pred(*i) != false`.
86
 
87
- *Remarks:* Stable [[algorithm.stable]].
88
-
89
  *Complexity:* Exactly `size()` applications of the corresponding
90
  predicate.
91
 
 
 
92
  ``` cpp
93
  size_type unique();
94
  template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
95
  ```
96
 
 
 
 
 
97
  *Effects:* Erases all but the first element from every consecutive group
98
- of equal elements referred to by the iterator `i` in the range
99
- \[`first + 1`, `last`) for which `*i == *(i-1)` (for the version of
100
- `unique` with no arguments) or `pred(*i, *(i - 1))` (for the version of
101
- `unique` with a predicate argument) holds. Invalidates only the
102
- iterators and references to the erased elements.
103
 
104
  *Returns:* The number of elements erased.
105
 
106
- *Throws:* Nothing unless an exception is thrown by `*i == *(i-1)` or
107
- `pred(*i, *(i - 1))`
108
 
109
- *Complexity:* If the range `[first, last)` is not empty, exactly
110
- `(last - first) - 1` applications of the corresponding predicate,
111
- otherwise no applications of the predicate.
112
 
113
  ``` cpp
114
  void merge(list& x);
115
  void merge(list&& x);
116
  template<class Compare> void merge(list& x, Compare comp);
117
  template<class Compare> void merge(list&& x, Compare comp);
118
  ```
119
 
120
- *Preconditions:* Both the list and the argument list shall be sorted
121
- with respect to the comparator `operator<` (for the first two overloads)
122
- or `comp` (for the last two overloads), and
123
- `get_allocator() == x.get_allocator()` is `true`.
124
 
125
- *Effects:* If `addressof(x) == this`, does nothing; otherwise, merges
126
- the two sorted ranges `[begin(), end())` and `[x.begin(), x.end())`. The
127
- result is a range in which the elements will be sorted in non-decreasing
128
- order according to the ordering defined by `comp`; that is, for every
129
- iterator `i`, in the range other than the first, the condition
130
- `comp(*i, *(i - 1))` will be `false`. Pointers and references to the
131
- moved elements of `x` now refer to those same elements but as members of
132
- `*this`. Iterators referring to the moved elements will continue to
133
- refer to their elements, but they now behave as iterators into `*this`,
134
- not into `x`.
135
 
136
- *Remarks:* Stable [[algorithm.stable]]. If `addressof(x) != this`, the
137
- range `[x.begin(), x.end())` is empty after the merge. No elements are
138
- copied by this operation.
 
 
 
 
139
 
140
- *Complexity:* At most `size() + x.size() - 1` applications of `comp` if
141
- `addressof(x) != this`; otherwise, no applications of `comp` are
142
- performed. If an exception is thrown other than by a comparison there
143
- are no effects.
 
 
144
 
145
  ``` cpp
146
  void reverse() noexcept;
147
  ```
148
 
@@ -159,9 +159,9 @@ template<class Compare> void sort(Compare comp);
159
  *Effects:* Sorts the list according to the `operator<` or a `Compare`
160
  function object. If an exception is thrown, the order of the elements in
161
  `*this` is unspecified. Does not affect the validity of iterators and
162
  references.
163
 
164
- *Remarks:* Stable [[algorithm.stable]].
165
-
166
  *Complexity:* Approximately N log N comparisons, where `N == size()`.
167
 
 
 
 
1
  #### Operations <a id="list.ops">[[list.ops]]</a>
2
 
3
  Since lists allow fast insertion and erasing from the middle of a list,
4
+ certain operations are provided specifically for them.[^3]
5
+
6
+ In this subclause, arguments for a template parameter named `Predicate`
7
+ or `BinaryPredicate` shall meet the corresponding requirements in
8
+ [[algorithms.requirements]]. The semantics of `i + n` and `i - n`, where
9
+ `i` is an iterator into the list and `n` is an integer, are the same as
10
+ those of `next(i, n)` and `prev(i, n)`, respectively. For `merge` and
11
+ `sort`, the definitions and requirements in [[alg.sorting]] apply.
12
 
13
  `list` provides three splice operations that destructively move elements
14
  from one list to another. The behavior of splice operations is undefined
15
  if `get_allocator() !=
16
  x.get_allocator()`.
 
85
  *Returns:* The number of elements erased.
86
 
87
  *Throws:* Nothing unless an exception is thrown by `*i == value` or
88
  `pred(*i) != false`.
89
 
 
 
90
  *Complexity:* Exactly `size()` applications of the corresponding
91
  predicate.
92
 
93
+ *Remarks:* Stable [[algorithm.stable]].
94
+
95
  ``` cpp
96
  size_type unique();
97
  template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
98
  ```
99
 
100
+ Let `binary_pred` be `equal_to<>{}` for the first overload.
101
+
102
+ *Preconditions:* `binary_pred` is an equivalence relation.
103
+
104
  *Effects:* Erases all but the first element from every consecutive group
105
+ of equivalent elements. That is, for a nonempty list, erases all
106
+ elements referred to by the iterator `i` in the range \[`begin() + 1`,
107
+ `end()`) for which `binary_pred(*i, *(i - 1))` is `true`. Invalidates
108
+ only the iterators and references to the erased elements.
 
109
 
110
  *Returns:* The number of elements erased.
111
 
112
+ *Throws:* Nothing unless an exception is thrown by the predicate.
 
113
 
114
+ *Complexity:* If `empty()` is `false`, exactly `size() - 1` applications
115
+ of the corresponding predicate, otherwise no applications of the
116
+ predicate.
117
 
118
  ``` cpp
119
  void merge(list& x);
120
  void merge(list&& x);
121
  template<class Compare> void merge(list& x, Compare comp);
122
  template<class Compare> void merge(list&& x, Compare comp);
123
  ```
124
 
125
+ Let `comp` be `less<>` for the first two overloads.
 
 
 
126
 
127
+ *Preconditions:* `*this` and `x` are both sorted with respect to the
128
+ comparator `comp`, and `get_allocator() == x.get_allocator()` is `true`.
 
 
 
 
 
 
 
 
129
 
130
+ *Effects:* If `addressof(x) == this`, there are no effects. Otherwise,
131
+ merges the two sorted ranges \[`begin()`, `end()`) and \[`x.begin()`,
132
+ `x.end()`). The result is a range that is sorted with respect to the
133
+ comparator `comp`. Pointers and references to the moved elements of `x`
134
+ now refer to those same elements but as members of `*this`. Iterators
135
+ referring to the moved elements will continue to refer to their
136
+ elements, but they now behave as iterators into `*this`, not into `x`.
137
 
138
+ *Complexity:* At most `size() + x.size() - 1` comparisons if
139
+ `addressof(x) != this`; otherwise, no comparisons are performed.
140
+
141
+ *Remarks:* Stable [[algorithm.stable]]. If `addressof(x) != this`, `x`
142
+ is empty after the merge. No elements are copied by this operation. If
143
+ an exception is thrown other than by a comparison there are no effects.
144
 
145
  ``` cpp
146
  void reverse() noexcept;
147
  ```
148
 
 
159
  *Effects:* Sorts the list according to the `operator<` or a `Compare`
160
  function object. If an exception is thrown, the order of the elements in
161
  `*this` is unspecified. Does not affect the validity of iterators and
162
  references.
163
 
 
 
164
  *Complexity:* Approximately N log N comparisons, where `N == size()`.
165
 
166
+ *Remarks:* Stable [[algorithm.stable]].
167
+