From Jason Turner

[multiset]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfzfowh4s/{from.md → to.md} +46 -51
tmp/tmpfzfowh4s/{from.md → to.md} RENAMED
@@ -1,33 +1,33 @@
1
  ### Class template `multiset` <a id="multiset">[[multiset]]</a>
2
 
3
- #### Class template `multiset` overview <a id="multiset.overview">[[multiset.overview]]</a>
4
 
5
  A `multiset` is an associative container that supports equivalent keys
6
  (possibly contains multiple copies of the same key value) and provides
7
  for fast retrieval of the keys themselves. The `multiset` class supports
8
  bidirectional iterators.
9
 
10
- A `multiset` satisfies all of the requirements of a container, of a
11
- reversible container ([[container.requirements]]), of an associative
12
- container ([[associative.reqmts]]), and of an allocator-aware container
13
- (Table  [[tab:containers.allocatoraware]]). `multiset` also provides
14
- most operations described in  [[associative.reqmts]] for duplicate keys.
15
- This means that a `multiset` supports the `a_eq` operations in 
16
- [[associative.reqmts]] but not the `a_uniq` operations. For a
17
- `multiset<Key>` both the `key_type` and `value_type` are `Key`.
18
- Descriptions are provided here only for operations on `multiset` that
19
- are not described in one of these tables and for operations where there
20
- is additional semantic information.
21
 
22
  ``` cpp
23
  namespace std {
24
  template<class Key, class Compare = less<Key>,
25
  class Allocator = allocator<Key>>
26
  class multiset {
27
  public:
28
- // types:
29
  using key_type = Key;
30
  using key_compare = Compare;
31
  using value_type = Key;
32
  using value_compare = Compare;
33
  using allocator_type = Allocator;
@@ -67,11 +67,11 @@ namespace std {
67
  noexcept(allocator_traits<Allocator>::is_always_equal::value &&
68
  is_nothrow_move_assignable_v<Compare>);
69
  multiset& operator=(initializer_list<value_type>);
70
  allocator_type get_allocator() const noexcept;
71
 
72
- // iterators:
73
  iterator begin() noexcept;
74
  const_iterator begin() const noexcept;
75
  iterator end() noexcept;
76
  const_iterator end() const noexcept;
77
 
@@ -83,16 +83,16 @@ namespace std {
83
  const_iterator cbegin() const noexcept;
84
  const_iterator cend() const noexcept;
85
  const_reverse_iterator crbegin() const noexcept;
86
  const_reverse_iterator crend() const noexcept;
87
 
88
- // capacity:
89
- bool empty() const noexcept;
90
  size_type size() const noexcept;
91
  size_type max_size() const noexcept;
92
 
93
- // modifiers:
94
  template<class... Args> iterator emplace(Args&&... args);
95
  template<class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
96
  iterator insert(const value_type& x);
97
  iterator insert(value_type&& x);
98
  iterator insert(const_iterator position, const value_type& x);
@@ -122,23 +122,26 @@ namespace std {
122
  template<class C2>
123
  void merge(set<Key, C2, Allocator>& source);
124
  template<class C2>
125
  void merge(set<Key, C2, Allocator>&& source);
126
 
127
- // observers:
128
  key_compare key_comp() const;
129
  value_compare value_comp() const;
130
 
131
- // set operations:
132
  iterator find(const key_type& x);
133
  const_iterator find(const key_type& x) const;
134
  template<class K> iterator find(const K& x);
135
  template<class K> const_iterator find(const K& x) const;
136
 
137
  size_type count(const key_type& x) const;
138
  template<class K> size_type count(const K& x) const;
139
 
 
 
 
140
  iterator lower_bound(const key_type& x);
141
  const_iterator lower_bound(const key_type& x) const;
142
  template<class K> iterator lower_bound(const K& x);
143
  template<class K> const_iterator lower_bound(const K& x) const;
144
 
@@ -154,56 +157,37 @@ namespace std {
154
  template<class K>
155
  pair<const_iterator, const_iterator> equal_range(const K& x) const;
156
  };
157
 
158
  template<class InputIterator,
159
- class Compare = less<typename iterator_traits<InputIterator>::value_type>,
160
- class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
161
  multiset(InputIterator, InputIterator,
162
  Compare = Compare(), Allocator = Allocator())
163
- -> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>;
164
 
165
  template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
166
  multiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
167
  -> multiset<Key, Compare, Allocator>;
168
 
169
  template<class InputIterator, class Allocator>
170
  multiset(InputIterator, InputIterator, Allocator)
171
- -> multiset<typename iterator_traits<InputIterator>::value_type,
172
- less<typename iterator_traits<InputIterator>::value_type>, Allocator>;
173
 
174
  template<class Key, class Allocator>
175
  multiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>;
176
 
177
- template <class Key, class Compare, class Allocator>
178
- bool operator==(const multiset<Key, Compare, Allocator>& x,
179
- const multiset<Key, Compare, Allocator>& y);
180
- template <class Key, class Compare, class Allocator>
181
- bool operator< (const multiset<Key, Compare, Allocator>& x,
182
- const multiset<Key, Compare, Allocator>& y);
183
- template <class Key, class Compare, class Allocator>
184
- bool operator!=(const multiset<Key, Compare, Allocator>& x,
185
- const multiset<Key, Compare, Allocator>& y);
186
- template <class Key, class Compare, class Allocator>
187
- bool operator> (const multiset<Key, Compare, Allocator>& x,
188
- const multiset<Key, Compare, Allocator>& y);
189
- template <class Key, class Compare, class Allocator>
190
- bool operator>=(const multiset<Key, Compare, Allocator>& x,
191
- const multiset<Key, Compare, Allocator>& y);
192
- template <class Key, class Compare, class Allocator>
193
- bool operator<=(const multiset<Key, Compare, Allocator>& x,
194
- const multiset<Key, Compare, Allocator>& y);
195
-
196
- // [multiset.special], specialized algorithms
197
  template<class Key, class Compare, class Allocator>
198
  void swap(multiset<Key, Compare, Allocator>& x,
199
  multiset<Key, Compare, Allocator>& y)
200
  noexcept(noexcept(x.swap(y)));
201
  }
202
  ```
203
 
204
- #### `multiset` constructors <a id="multiset.cons">[[multiset.cons]]</a>
205
 
206
  ``` cpp
207
  explicit multiset(const Compare& comp, const Allocator& = Allocator());
208
  ```
209
 
@@ -223,16 +207,27 @@ object and allocator, and inserts elements from the range \[`first`,
223
  `last`).
224
 
225
  *Complexity:* Linear in N if the range \[`first`, `last`) is already
226
  sorted using `comp` and otherwise N log N, where N is `last - first`.
227
 
228
- #### `multiset` specialized algorithms <a id="multiset.special">[[multiset.special]]</a>
229
 
230
  ``` cpp
231
- template <class Key, class Compare, class Allocator>
232
- void swap(multiset<Key, Compare, Allocator>& x,
233
- multiset<Key, Compare, Allocator>& y)
234
- noexcept(noexcept(x.swap(y)));
235
  ```
236
 
237
- *Effects:* As if by `x.swap(y)`.
 
 
 
 
 
 
 
 
 
 
 
 
238
 
 
1
  ### Class template `multiset` <a id="multiset">[[multiset]]</a>
2
 
3
+ #### Overview <a id="multiset.overview">[[multiset.overview]]</a>
4
 
5
  A `multiset` is an associative container that supports equivalent keys
6
  (possibly contains multiple copies of the same key value) and provides
7
  for fast retrieval of the keys themselves. The `multiset` class supports
8
  bidirectional iterators.
9
 
10
+ A `multiset` meets all of the requirements of a container, of a
11
+ reversible container [[container.requirements]], of an associative
12
+ container [[associative.reqmts]], and of an allocator-aware container (
13
+ [[container.alloc.req]]). `multiset` also provides most operations
14
+ described in  [[associative.reqmts]] for duplicate keys. This means that
15
+ a `multiset` supports the `a_eq` operations in  [[associative.reqmts]]
16
+ but not the `a_uniq` operations. For a `multiset<Key>` both the
17
+ `key_type` and `value_type` are `Key`. Descriptions are provided here
18
+ only for operations on `multiset` that are not described in one of these
19
+ tables and for operations where there is additional semantic
20
+ information.
21
 
22
  ``` cpp
23
  namespace std {
24
  template<class Key, class Compare = less<Key>,
25
  class Allocator = allocator<Key>>
26
  class multiset {
27
  public:
28
+ // types
29
  using key_type = Key;
30
  using key_compare = Compare;
31
  using value_type = Key;
32
  using value_compare = Compare;
33
  using allocator_type = Allocator;
 
67
  noexcept(allocator_traits<Allocator>::is_always_equal::value &&
68
  is_nothrow_move_assignable_v<Compare>);
69
  multiset& operator=(initializer_list<value_type>);
70
  allocator_type get_allocator() const noexcept;
71
 
72
+ // iterators
73
  iterator begin() noexcept;
74
  const_iterator begin() const noexcept;
75
  iterator end() noexcept;
76
  const_iterator end() const noexcept;
77
 
 
83
  const_iterator cbegin() const noexcept;
84
  const_iterator cend() const noexcept;
85
  const_reverse_iterator crbegin() const noexcept;
86
  const_reverse_iterator crend() const noexcept;
87
 
88
+ // capacity
89
+ [[nodiscard]] bool empty() const noexcept;
90
  size_type size() const noexcept;
91
  size_type max_size() const noexcept;
92
 
93
+ // modifiers
94
  template<class... Args> iterator emplace(Args&&... args);
95
  template<class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
96
  iterator insert(const value_type& x);
97
  iterator insert(value_type&& x);
98
  iterator insert(const_iterator position, const value_type& x);
 
122
  template<class C2>
123
  void merge(set<Key, C2, Allocator>& source);
124
  template<class C2>
125
  void merge(set<Key, C2, Allocator>&& source);
126
 
127
+ // observers
128
  key_compare key_comp() const;
129
  value_compare value_comp() const;
130
 
131
+ // set operations
132
  iterator find(const key_type& x);
133
  const_iterator find(const key_type& x) const;
134
  template<class K> iterator find(const K& x);
135
  template<class K> const_iterator find(const K& x) const;
136
 
137
  size_type count(const key_type& x) const;
138
  template<class K> size_type count(const K& x) const;
139
 
140
+ bool contains(const key_type& x) const;
141
+ template<class K> bool contains(const K& x) const;
142
+
143
  iterator lower_bound(const key_type& x);
144
  const_iterator lower_bound(const key_type& x) const;
145
  template<class K> iterator lower_bound(const K& x);
146
  template<class K> const_iterator lower_bound(const K& x) const;
147
 
 
157
  template<class K>
158
  pair<const_iterator, const_iterator> equal_range(const K& x) const;
159
  };
160
 
161
  template<class InputIterator,
162
+ class Compare = less<iter-value-type<InputIterator>>,
163
+ class Allocator = allocator<iter-value-type<InputIterator>>>
164
  multiset(InputIterator, InputIterator,
165
  Compare = Compare(), Allocator = Allocator())
166
+ -> multiset<iter-value-type<InputIterator>, Compare, Allocator>;
167
 
168
  template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
169
  multiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
170
  -> multiset<Key, Compare, Allocator>;
171
 
172
  template<class InputIterator, class Allocator>
173
  multiset(InputIterator, InputIterator, Allocator)
174
+ -> multiset<iter-value-type<InputIterator>,
175
+ less<iter-value-type<InputIterator>>, Allocator>;
176
 
177
  template<class Key, class Allocator>
178
  multiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>;
179
 
180
+ // swap
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  template<class Key, class Compare, class Allocator>
182
  void swap(multiset<Key, Compare, Allocator>& x,
183
  multiset<Key, Compare, Allocator>& y)
184
  noexcept(noexcept(x.swap(y)));
185
  }
186
  ```
187
 
188
+ #### Constructors <a id="multiset.cons">[[multiset.cons]]</a>
189
 
190
  ``` cpp
191
  explicit multiset(const Compare& comp, const Allocator& = Allocator());
192
  ```
193
 
 
207
  `last`).
208
 
209
  *Complexity:* Linear in N if the range \[`first`, `last`) is already
210
  sorted using `comp` and otherwise N log N, where N is `last - first`.
211
 
212
+ #### Erasure <a id="multiset.erasure">[[multiset.erasure]]</a>
213
 
214
  ``` cpp
215
+ template<class Key, class Compare, class Allocator, class Predicate>
216
+ typename multiset<Key, Compare, Allocator>::size_type
217
+ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred);
 
218
  ```
219
 
220
+ *Effects:* Equivalent to:
221
+
222
+ ``` cpp
223
+ auto original_size = c.size();
224
+ for (auto i = c.begin(), last = c.end(); i != last; ) {
225
+ if (pred(*i)) {
226
+ i = c.erase(i);
227
+ } else {
228
+ ++i;
229
+ }
230
+ }
231
+ return original_size - c.size();
232
+ ```
233