blob: de23ca2a396d3ad80b7e17c9ecfdef5a8473b353 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001// -*- C++ -*-
2//===-------------------------- unordered_set -----------------------------===//
3//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00005//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_UNORDERED_SET
12#define _LIBCPP_UNORDERED_SET
13
14/*
15
16 unordered_set synopsis
17
18#include <initializer_list>
19
20namespace std
21{
22
23template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
24 class Alloc = allocator<Value>>
25class unordered_set
26{
27public:
28 // types
29 typedef Value key_type;
30 typedef key_type value_type;
31 typedef Hash hasher;
32 typedef Pred key_equal;
33 typedef Alloc allocator_type;
34 typedef value_type& reference;
35 typedef const value_type& const_reference;
36 typedef typename allocator_traits<allocator_type>::pointer pointer;
37 typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
38 typedef typename allocator_traits<allocator_type>::size_type size_type;
39 typedef typename allocator_traits<allocator_type>::difference_type difference_type;
40
41 typedef /unspecified/ iterator;
42 typedef /unspecified/ const_iterator;
43 typedef /unspecified/ local_iterator;
44 typedef /unspecified/ const_local_iterator;
45
Erik Pilkingtonb0386a52018-08-01 01:33:38 +000046 typedef unspecified node_type unspecified; // C++17
47 typedef INSERT_RETURN_TYPE<iterator, node_type> insert_return_type; // C++17
48
Howard Hinnant557da862011-06-04 20:18:37 +000049 unordered_set()
50 noexcept(
51 is_nothrow_default_constructible<hasher>::value &&
52 is_nothrow_default_constructible<key_equal>::value &&
53 is_nothrow_default_constructible<allocator_type>::value);
54 explicit unordered_set(size_type n, const hasher& hf = hasher(),
Howard Hinnant3e519522010-05-11 19:42:16 +000055 const key_equal& eql = key_equal(),
56 const allocator_type& a = allocator_type());
57 template <class InputIterator>
58 unordered_set(InputIterator f, InputIterator l,
59 size_type n = 0, const hasher& hf = hasher(),
60 const key_equal& eql = key_equal(),
61 const allocator_type& a = allocator_type());
62 explicit unordered_set(const allocator_type&);
63 unordered_set(const unordered_set&);
64 unordered_set(const unordered_set&, const Allocator&);
Howard Hinnant557da862011-06-04 20:18:37 +000065 unordered_set(unordered_set&&)
66 noexcept(
67 is_nothrow_move_constructible<hasher>::value &&
68 is_nothrow_move_constructible<key_equal>::value &&
69 is_nothrow_move_constructible<allocator_type>::value);
Howard Hinnant3e519522010-05-11 19:42:16 +000070 unordered_set(unordered_set&&, const Allocator&);
71 unordered_set(initializer_list<value_type>, size_type n = 0,
72 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
73 const allocator_type& a = allocator_type());
Marshall Clow45b983c2013-09-30 21:33:51 +000074 unordered_set(size_type n, const allocator_type& a); // C++14
75 unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14
76 template <class InputIterator>
77 unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
78 template <class InputIterator>
79 unordered_set(InputIterator f, InputIterator l, size_type n,
80 const hasher& hf, const allocator_type& a); // C++14
81 unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
82 unordered_set(initializer_list<value_type> il, size_type n,
83 const hasher& hf, const allocator_type& a); // C++14
Howard Hinnant3e519522010-05-11 19:42:16 +000084 ~unordered_set();
85 unordered_set& operator=(const unordered_set&);
Howard Hinnant557da862011-06-04 20:18:37 +000086 unordered_set& operator=(unordered_set&&)
87 noexcept(
88 allocator_type::propagate_on_container_move_assignment::value &&
89 is_nothrow_move_assignable<allocator_type>::value &&
90 is_nothrow_move_assignable<hasher>::value &&
91 is_nothrow_move_assignable<key_equal>::value);
Howard Hinnant3e519522010-05-11 19:42:16 +000092 unordered_set& operator=(initializer_list<value_type>);
93
Howard Hinnant557da862011-06-04 20:18:37 +000094 allocator_type get_allocator() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +000095
Howard Hinnant557da862011-06-04 20:18:37 +000096 bool empty() const noexcept;
97 size_type size() const noexcept;
98 size_type max_size() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +000099
Howard Hinnant557da862011-06-04 20:18:37 +0000100 iterator begin() noexcept;
101 iterator end() noexcept;
102 const_iterator begin() const noexcept;
103 const_iterator end() const noexcept;
104 const_iterator cbegin() const noexcept;
105 const_iterator cend() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +0000106
107 template <class... Args>
108 pair<iterator, bool> emplace(Args&&... args);
109 template <class... Args>
110 iterator emplace_hint(const_iterator position, Args&&... args);
111 pair<iterator, bool> insert(const value_type& obj);
112 pair<iterator, bool> insert(value_type&& obj);
113 iterator insert(const_iterator hint, const value_type& obj);
114 iterator insert(const_iterator hint, value_type&& obj);
115 template <class InputIterator>
116 void insert(InputIterator first, InputIterator last);
117 void insert(initializer_list<value_type>);
118
Erik Pilkingtonb0386a52018-08-01 01:33:38 +0000119 node_type extract(const_iterator position); // C++17
120 node_type extract(const key_type& x); // C++17
121 insert_return_type insert(node_type&& nh); // C++17
122 iterator insert(const_iterator hint, node_type&& nh); // C++17
123
Howard Hinnant3e519522010-05-11 19:42:16 +0000124 iterator erase(const_iterator position);
Marshall Clowec392962015-05-10 13:35:00 +0000125 iterator erase(iterator position); // C++14
Howard Hinnant3e519522010-05-11 19:42:16 +0000126 size_type erase(const key_type& k);
127 iterator erase(const_iterator first, const_iterator last);
Howard Hinnant557da862011-06-04 20:18:37 +0000128 void clear() noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +0000129
Erik Pilkington5c4e07a2018-10-31 17:31:35 +0000130 template<class H2, class P2>
131 void merge(unordered_set<Key, H2, P2, Allocator>& source); // C++17
132 template<class H2, class P2>
133 void merge(unordered_set<Key, H2, P2, Allocator>&& source); // C++17
134 template<class H2, class P2>
135 void merge(unordered_multiset<Key, H2, P2, Allocator>& source); // C++17
136 template<class H2, class P2>
137 void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); // C++17
138
Howard Hinnant557da862011-06-04 20:18:37 +0000139 void swap(unordered_set&)
Marshall Clowe3fbe142015-07-13 20:04:56 +0000140 noexcept(allocator_traits<Allocator>::is_always_equal::value &&
141 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
142 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
Howard Hinnant3e519522010-05-11 19:42:16 +0000143
144 hasher hash_function() const;
145 key_equal key_eq() const;
146
147 iterator find(const key_type& k);
148 const_iterator find(const key_type& k) const;
149 size_type count(const key_type& k) const;
150 pair<iterator, iterator> equal_range(const key_type& k);
151 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
152
Howard Hinnant557da862011-06-04 20:18:37 +0000153 size_type bucket_count() const noexcept;
154 size_type max_bucket_count() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +0000155
156 size_type bucket_size(size_type n) const;
157 size_type bucket(const key_type& k) const;
158
159 local_iterator begin(size_type n);
160 local_iterator end(size_type n);
161 const_local_iterator begin(size_type n) const;
162 const_local_iterator end(size_type n) const;
163 const_local_iterator cbegin(size_type n) const;
164 const_local_iterator cend(size_type n) const;
165
Howard Hinnant557da862011-06-04 20:18:37 +0000166 float load_factor() const noexcept;
167 float max_load_factor() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +0000168 void max_load_factor(float z);
169 void rehash(size_type n);
170 void reserve(size_type n);
171};
172
173template <class Value, class Hash, class Pred, class Alloc>
174 void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
Howard Hinnant557da862011-06-04 20:18:37 +0000175 unordered_set<Value, Hash, Pred, Alloc>& y)
176 noexcept(noexcept(x.swap(y)));
Howard Hinnant3e519522010-05-11 19:42:16 +0000177
178template <class Value, class Hash, class Pred, class Alloc>
179 bool
180 operator==(const unordered_set<Value, Hash, Pred, Alloc>& x,
181 const unordered_set<Value, Hash, Pred, Alloc>& y);
182
183template <class Value, class Hash, class Pred, class Alloc>
184 bool
185 operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x,
186 const unordered_set<Value, Hash, Pred, Alloc>& y);
187
188template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
189 class Alloc = allocator<Value>>
190class unordered_multiset
191{
192public:
193 // types
194 typedef Value key_type;
195 typedef key_type value_type;
196 typedef Hash hasher;
197 typedef Pred key_equal;
198 typedef Alloc allocator_type;
199 typedef value_type& reference;
200 typedef const value_type& const_reference;
201 typedef typename allocator_traits<allocator_type>::pointer pointer;
202 typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
203 typedef typename allocator_traits<allocator_type>::size_type size_type;
204 typedef typename allocator_traits<allocator_type>::difference_type difference_type;
205
206 typedef /unspecified/ iterator;
207 typedef /unspecified/ const_iterator;
208 typedef /unspecified/ local_iterator;
209 typedef /unspecified/ const_local_iterator;
210
Erik Pilkingtonb0386a52018-08-01 01:33:38 +0000211 typedef unspecified node_type unspecified; // C++17
212
Howard Hinnant557da862011-06-04 20:18:37 +0000213 unordered_multiset()
214 noexcept(
215 is_nothrow_default_constructible<hasher>::value &&
216 is_nothrow_default_constructible<key_equal>::value &&
217 is_nothrow_default_constructible<allocator_type>::value);
218 explicit unordered_multiset(size_type n, const hasher& hf = hasher(),
Howard Hinnant3e519522010-05-11 19:42:16 +0000219 const key_equal& eql = key_equal(),
220 const allocator_type& a = allocator_type());
221 template <class InputIterator>
222 unordered_multiset(InputIterator f, InputIterator l,
223 size_type n = 0, const hasher& hf = hasher(),
224 const key_equal& eql = key_equal(),
225 const allocator_type& a = allocator_type());
226 explicit unordered_multiset(const allocator_type&);
227 unordered_multiset(const unordered_multiset&);
228 unordered_multiset(const unordered_multiset&, const Allocator&);
Howard Hinnant557da862011-06-04 20:18:37 +0000229 unordered_multiset(unordered_multiset&&)
230 noexcept(
231 is_nothrow_move_constructible<hasher>::value &&
232 is_nothrow_move_constructible<key_equal>::value &&
233 is_nothrow_move_constructible<allocator_type>::value);
Howard Hinnant3e519522010-05-11 19:42:16 +0000234 unordered_multiset(unordered_multiset&&, const Allocator&);
235 unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
236 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
237 const allocator_type& a = allocator_type());
Marshall Clow45b983c2013-09-30 21:33:51 +0000238 unordered_multiset(size_type n, const allocator_type& a); // C++14
239 unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14
240 template <class InputIterator>
241 unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
242 template <class InputIterator>
243 unordered_multiset(InputIterator f, InputIterator l, size_type n,
244 const hasher& hf, const allocator_type& a); // C++14
245 unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
246 unordered_multiset(initializer_list<value_type> il, size_type n,
247 const hasher& hf, const allocator_type& a); // C++14
Howard Hinnant3e519522010-05-11 19:42:16 +0000248 ~unordered_multiset();
249 unordered_multiset& operator=(const unordered_multiset&);
Howard Hinnant557da862011-06-04 20:18:37 +0000250 unordered_multiset& operator=(unordered_multiset&&)
251 noexcept(
252 allocator_type::propagate_on_container_move_assignment::value &&
253 is_nothrow_move_assignable<allocator_type>::value &&
254 is_nothrow_move_assignable<hasher>::value &&
255 is_nothrow_move_assignable<key_equal>::value);
Howard Hinnant3e519522010-05-11 19:42:16 +0000256 unordered_multiset& operator=(initializer_list<value_type>);
257
Howard Hinnant557da862011-06-04 20:18:37 +0000258 allocator_type get_allocator() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +0000259
Howard Hinnant557da862011-06-04 20:18:37 +0000260 bool empty() const noexcept;
261 size_type size() const noexcept;
262 size_type max_size() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +0000263
Howard Hinnant557da862011-06-04 20:18:37 +0000264 iterator begin() noexcept;
265 iterator end() noexcept;
266 const_iterator begin() const noexcept;
267 const_iterator end() const noexcept;
268 const_iterator cbegin() const noexcept;
269 const_iterator cend() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +0000270
271 template <class... Args>
272 iterator emplace(Args&&... args);
273 template <class... Args>
274 iterator emplace_hint(const_iterator position, Args&&... args);
275 iterator insert(const value_type& obj);
276 iterator insert(value_type&& obj);
277 iterator insert(const_iterator hint, const value_type& obj);
278 iterator insert(const_iterator hint, value_type&& obj);
279 template <class InputIterator>
280 void insert(InputIterator first, InputIterator last);
281 void insert(initializer_list<value_type>);
282
Erik Pilkingtonb0386a52018-08-01 01:33:38 +0000283 node_type extract(const_iterator position); // C++17
284 node_type extract(const key_type& x); // C++17
285 iterator insert(node_type&& nh); // C++17
286 iterator insert(const_iterator hint, node_type&& nh); // C++17
287
Howard Hinnant3e519522010-05-11 19:42:16 +0000288 iterator erase(const_iterator position);
Marshall Clowec392962015-05-10 13:35:00 +0000289 iterator erase(iterator position); // C++14
Howard Hinnant3e519522010-05-11 19:42:16 +0000290 size_type erase(const key_type& k);
291 iterator erase(const_iterator first, const_iterator last);
Howard Hinnant557da862011-06-04 20:18:37 +0000292 void clear() noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +0000293
Erik Pilkington5c4e07a2018-10-31 17:31:35 +0000294 template<class H2, class P2>
295 void merge(unordered_multiset<Key, H2, P2, Allocator>& source); // C++17
296 template<class H2, class P2>
297 void merge(unordered_multiset<Key, H2, P2, Allocator>&& source); // C++17
298 template<class H2, class P2>
299 void merge(unordered_set<Key, H2, P2, Allocator>& source); // C++17
300 template<class H2, class P2>
301 void merge(unordered_set<Key, H2, P2, Allocator>&& source); // C++17
302
Howard Hinnant557da862011-06-04 20:18:37 +0000303 void swap(unordered_multiset&)
Marshall Clowe3fbe142015-07-13 20:04:56 +0000304 noexcept(allocator_traits<Allocator>::is_always_equal::value &&
305 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
306 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
Howard Hinnant3e519522010-05-11 19:42:16 +0000307
308 hasher hash_function() const;
309 key_equal key_eq() const;
310
311 iterator find(const key_type& k);
312 const_iterator find(const key_type& k) const;
313 size_type count(const key_type& k) const;
314 pair<iterator, iterator> equal_range(const key_type& k);
315 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
316
Howard Hinnant557da862011-06-04 20:18:37 +0000317 size_type bucket_count() const noexcept;
318 size_type max_bucket_count() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +0000319
320 size_type bucket_size(size_type n) const;
321 size_type bucket(const key_type& k) const;
322
323 local_iterator begin(size_type n);
324 local_iterator end(size_type n);
325 const_local_iterator begin(size_type n) const;
326 const_local_iterator end(size_type n) const;
327 const_local_iterator cbegin(size_type n) const;
328 const_local_iterator cend(size_type n) const;
329
Howard Hinnant557da862011-06-04 20:18:37 +0000330 float load_factor() const noexcept;
331 float max_load_factor() const noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +0000332 void max_load_factor(float z);
333 void rehash(size_type n);
334 void reserve(size_type n);
335};
336
337template <class Value, class Hash, class Pred, class Alloc>
338 void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
Howard Hinnant557da862011-06-04 20:18:37 +0000339 unordered_multiset<Value, Hash, Pred, Alloc>& y)
340 noexcept(noexcept(x.swap(y)));
Howard Hinnant3e519522010-05-11 19:42:16 +0000341
342template <class Value, class Hash, class Pred, class Alloc>
343 bool
344 operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
345 const unordered_multiset<Value, Hash, Pred, Alloc>& y);
346
347template <class Value, class Hash, class Pred, class Alloc>
348 bool
349 operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
350 const unordered_multiset<Value, Hash, Pred, Alloc>& y);
351} // std
352
353*/
354
355#include <__config>
356#include <__hash_table>
Erik Pilkingtonb0386a52018-08-01 01:33:38 +0000357#include <__node_handle>
Howard Hinnant3e519522010-05-11 19:42:16 +0000358#include <functional>
Marshall Clowf56972e2018-09-12 19:41:40 +0000359#include <version>
Howard Hinnant3e519522010-05-11 19:42:16 +0000360
Eric Fiselierc1bd9192014-08-10 23:53:08 +0000361#include <__debug>
362
Howard Hinnant073458b2011-10-17 20:05:10 +0000363#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnant3e519522010-05-11 19:42:16 +0000364#pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:10 +0000365#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000366
367_LIBCPP_BEGIN_NAMESPACE_STD
368
Erik Pilkington5c4e07a2018-10-31 17:31:35 +0000369template <class _Value, class _Hash, class _Pred, class _Alloc>
370class unordered_multiset;
371
Howard Hinnant3e519522010-05-11 19:42:16 +0000372template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
373 class _Alloc = allocator<_Value> >
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +0000374class _LIBCPP_TEMPLATE_VIS unordered_set
Howard Hinnant3e519522010-05-11 19:42:16 +0000375{
376public:
377 // types
378 typedef _Value key_type;
379 typedef key_type value_type;
380 typedef _Hash hasher;
381 typedef _Pred key_equal;
382 typedef _Alloc allocator_type;
383 typedef value_type& reference;
384 typedef const value_type& const_reference;
Howard Hinnantb24c8022013-07-23 22:01:58 +0000385 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
386 "Invalid allocator::value_type");
Howard Hinnant3e519522010-05-11 19:42:16 +0000387
388private:
389 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
390
391 __table __table_;
392
393public:
394 typedef typename __table::pointer pointer;
395 typedef typename __table::const_pointer const_pointer;
396 typedef typename __table::size_type size_type;
397 typedef typename __table::difference_type difference_type;
398
399 typedef typename __table::const_iterator iterator;
400 typedef typename __table::const_iterator const_iterator;
401 typedef typename __table::const_local_iterator local_iterator;
402 typedef typename __table::const_local_iterator const_local_iterator;
403
Erik Pilkingtonb0386a52018-08-01 01:33:38 +0000404#if _LIBCPP_STD_VER > 14
405 typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
406 typedef __insert_return_type<iterator, node_type> insert_return_type;
407#endif
408
Erik Pilkington5c4e07a2018-10-31 17:31:35 +0000409 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
410 friend class _LIBCPP_TEMPLATE_VIS unordered_set;
411 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
412 friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
413
Howard Hinnant789847d2010-09-23 18:58:28 +0000414 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000415 unordered_set()
416 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
Howard Hinnantb24c8022013-07-23 22:01:58 +0000417 {
418#if _LIBCPP_DEBUG_LEVEL >= 2
419 __get_db()->__insert_c(this);
420#endif
421 }
Howard Hinnant3e519522010-05-11 19:42:16 +0000422 explicit unordered_set(size_type __n, const hasher& __hf = hasher(),
423 const key_equal& __eql = key_equal());
Marshall Clow45b983c2013-09-30 21:33:51 +0000424#if _LIBCPP_STD_VER > 11
425 inline _LIBCPP_INLINE_VISIBILITY
426 unordered_set(size_type __n, const allocator_type& __a)
427 : unordered_set(__n, hasher(), key_equal(), __a) {}
428 inline _LIBCPP_INLINE_VISIBILITY
429 unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
430 : unordered_set(__n, __hf, key_equal(), __a) {}
431#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000432 unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql,
433 const allocator_type& __a);
434 template <class _InputIterator>
435 unordered_set(_InputIterator __first, _InputIterator __last);
436 template <class _InputIterator>
437 unordered_set(_InputIterator __first, _InputIterator __last,
438 size_type __n, const hasher& __hf = hasher(),
439 const key_equal& __eql = key_equal());
440 template <class _InputIterator>
441 unordered_set(_InputIterator __first, _InputIterator __last,
442 size_type __n, const hasher& __hf, const key_equal& __eql,
443 const allocator_type& __a);
Marshall Clow45b983c2013-09-30 21:33:51 +0000444#if _LIBCPP_STD_VER > 11
445 template <class _InputIterator>
446 inline _LIBCPP_INLINE_VISIBILITY
447 unordered_set(_InputIterator __first, _InputIterator __last,
448 size_type __n, const allocator_type& __a)
449 : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {}
450 template <class _InputIterator>
451 unordered_set(_InputIterator __first, _InputIterator __last,
452 size_type __n, const hasher& __hf, const allocator_type& __a)
453 : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
454#endif
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +0000455 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000456 explicit unordered_set(const allocator_type& __a);
457 unordered_set(const unordered_set& __u);
458 unordered_set(const unordered_set& __u, const allocator_type& __a);
Eric Fiselierf0f86ef2017-04-18 22:37:32 +0000459#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +0000460 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000461 unordered_set(unordered_set&& __u)
462 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
Howard Hinnant3e519522010-05-11 19:42:16 +0000463 unordered_set(unordered_set&& __u, const allocator_type& __a);
Howard Hinnant3e519522010-05-11 19:42:16 +0000464 unordered_set(initializer_list<value_type> __il);
465 unordered_set(initializer_list<value_type> __il, size_type __n,
466 const hasher& __hf = hasher(),
467 const key_equal& __eql = key_equal());
468 unordered_set(initializer_list<value_type> __il, size_type __n,
469 const hasher& __hf, const key_equal& __eql,
470 const allocator_type& __a);
Marshall Clow45b983c2013-09-30 21:33:51 +0000471#if _LIBCPP_STD_VER > 11
472 inline _LIBCPP_INLINE_VISIBILITY
473 unordered_set(initializer_list<value_type> __il, size_type __n,
474 const allocator_type& __a)
475 : unordered_set(__il, __n, hasher(), key_equal(), __a) {}
476 inline _LIBCPP_INLINE_VISIBILITY
477 unordered_set(initializer_list<value_type> __il, size_type __n,
478 const hasher& __hf, const allocator_type& __a)
479 : unordered_set(__il, __n, __hf, key_equal(), __a) {}
480#endif
Eric Fiselierf0f86ef2017-04-18 22:37:32 +0000481#endif // _LIBCPP_CXX03_LANG
Howard Hinnant3e519522010-05-11 19:42:16 +0000482 // ~unordered_set() = default;
Howard Hinnant5a336872011-07-01 19:24:36 +0000483 _LIBCPP_INLINE_VISIBILITY
484 unordered_set& operator=(const unordered_set& __u)
485 {
486 __table_ = __u.__table_;
487 return *this;
488 }
Eric Fiselierf0f86ef2017-04-18 22:37:32 +0000489#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +0000490 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000491 unordered_set& operator=(unordered_set&& __u)
492 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +0000493 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000494 unordered_set& operator=(initializer_list<value_type> __il);
Eric Fiselierf0f86ef2017-04-18 22:37:32 +0000495#endif // _LIBCPP_CXX03_LANG
Howard Hinnant3e519522010-05-11 19:42:16 +0000496
Howard Hinnant789847d2010-09-23 18:58:28 +0000497 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000498 allocator_type get_allocator() const _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:16 +0000499 {return allocator_type(__table_.__node_alloc());}
500
Marshall Clow72c8fad2017-11-15 05:51:26 +0000501 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000502 bool empty() const _NOEXCEPT {return __table_.size() == 0;}
Howard Hinnant789847d2010-09-23 18:58:28 +0000503 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000504 size_type size() const _NOEXCEPT {return __table_.size();}
Howard Hinnant789847d2010-09-23 18:58:28 +0000505 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000506 size_type max_size() const _NOEXCEPT {return __table_.max_size();}
Howard Hinnant3e519522010-05-11 19:42:16 +0000507
Howard Hinnant789847d2010-09-23 18:58:28 +0000508 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000509 iterator begin() _NOEXCEPT {return __table_.begin();}
Howard Hinnant789847d2010-09-23 18:58:28 +0000510 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000511 iterator end() _NOEXCEPT {return __table_.end();}
Howard Hinnant789847d2010-09-23 18:58:28 +0000512 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000513 const_iterator begin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnant789847d2010-09-23 18:58:28 +0000514 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000515 const_iterator end() const _NOEXCEPT {return __table_.end();}
Howard Hinnant789847d2010-09-23 18:58:28 +0000516 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000517 const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnant789847d2010-09-23 18:58:28 +0000518 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000519 const_iterator cend() const _NOEXCEPT {return __table_.end();}
Howard Hinnant3e519522010-05-11 19:42:16 +0000520
Eric Fiselierf0f86ef2017-04-18 22:37:32 +0000521#ifndef _LIBCPP_CXX03_LANG
Howard Hinnant3e519522010-05-11 19:42:16 +0000522 template <class... _Args>
Howard Hinnant789847d2010-09-23 18:58:28 +0000523 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000524 pair<iterator, bool> emplace(_Args&&... __args)
Howard Hinnantce48a112011-06-30 21:18:19 +0000525 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
Howard Hinnant3e519522010-05-11 19:42:16 +0000526 template <class... _Args>
Howard Hinnant789847d2010-09-23 18:58:28 +0000527 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb24c8022013-07-23 22:01:58 +0000528#if _LIBCPP_DEBUG_LEVEL >= 2
529 iterator emplace_hint(const_iterator __p, _Args&&... __args)
530 {
531 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
532 "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"
533 " referring to this unordered_set");
534 return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
535 }
536#else
Howard Hinnant3e519522010-05-11 19:42:16 +0000537 iterator emplace_hint(const_iterator, _Args&&... __args)
Howard Hinnantce48a112011-06-30 21:18:19 +0000538 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
Howard Hinnantb24c8022013-07-23 22:01:58 +0000539#endif
Eric Fiselierf0f86ef2017-04-18 22:37:32 +0000540
Howard Hinnant789847d2010-09-23 18:58:28 +0000541 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000542 pair<iterator, bool> insert(value_type&& __x)
Howard Hinnantce48a112011-06-30 21:18:19 +0000543 {return __table_.__insert_unique(_VSTD::move(__x));}
Howard Hinnant789847d2010-09-23 18:58:28 +0000544 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb24c8022013-07-23 22:01:58 +0000545#if _LIBCPP_DEBUG_LEVEL >= 2
546 iterator insert(const_iterator __p, value_type&& __x)
547 {
548 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
549 "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
550 " referring to this unordered_set");
551 return insert(_VSTD::move(__x)).first;
552 }
553#else
Howard Hinnant3e519522010-05-11 19:42:16 +0000554 iterator insert(const_iterator, value_type&& __x)
Howard Hinnantce48a112011-06-30 21:18:19 +0000555 {return insert(_VSTD::move(__x)).first;}
Howard Hinnantb24c8022013-07-23 22:01:58 +0000556#endif
Howard Hinnant789847d2010-09-23 18:58:28 +0000557 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000558 void insert(initializer_list<value_type> __il)
559 {insert(__il.begin(), __il.end());}
Eric Fiselierf0f86ef2017-04-18 22:37:32 +0000560#endif // _LIBCPP_CXX03_LANG
561 _LIBCPP_INLINE_VISIBILITY
562 pair<iterator, bool> insert(const value_type& __x)
563 {return __table_.__insert_unique(__x);}
564
565 _LIBCPP_INLINE_VISIBILITY
566#if _LIBCPP_DEBUG_LEVEL >= 2
567 iterator insert(const_iterator __p, const value_type& __x)
568 {
569 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
570 "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"
571 " referring to this unordered_set");
572 return insert(__x).first;
573 }
574#else
575 iterator insert(const_iterator, const value_type& __x)
576 {return insert(__x).first;}
577#endif
578 template <class _InputIterator>
579 _LIBCPP_INLINE_VISIBILITY
580 void insert(_InputIterator __first, _InputIterator __last);
Howard Hinnant3e519522010-05-11 19:42:16 +0000581
Howard Hinnant789847d2010-09-23 18:58:28 +0000582 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000583 iterator erase(const_iterator __p) {return __table_.erase(__p);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000584 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000585 size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000586 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000587 iterator erase(const_iterator __first, const_iterator __last)
588 {return __table_.erase(__first, __last);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000589 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000590 void clear() _NOEXCEPT {__table_.clear();}
Howard Hinnant3e519522010-05-11 19:42:16 +0000591
Erik Pilkingtonb0386a52018-08-01 01:33:38 +0000592#if _LIBCPP_STD_VER > 14
593 _LIBCPP_INLINE_VISIBILITY
594 insert_return_type insert(node_type&& __nh)
595 {
596 _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
597 "node_type with incompatible allocator passed to unordered_set::insert()");
598 return __table_.template __node_handle_insert_unique<
599 node_type, insert_return_type>(_VSTD::move(__nh));
600 }
601 _LIBCPP_INLINE_VISIBILITY
602 iterator insert(const_iterator __h, node_type&& __nh)
603 {
604 _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
605 "node_type with incompatible allocator passed to unordered_set::insert()");
606 return __table_.template __node_handle_insert_unique<node_type>(
607 __h, _VSTD::move(__nh));
608 }
609 _LIBCPP_INLINE_VISIBILITY
610 node_type extract(key_type const& __key)
611 {
612 return __table_.template __node_handle_extract<node_type>(__key);
613 }
614 _LIBCPP_INLINE_VISIBILITY
615 node_type extract(const_iterator __it)
616 {
617 return __table_.template __node_handle_extract<node_type>(__it);
618 }
Erik Pilkington5c4e07a2018-10-31 17:31:35 +0000619
620 template<class _H2, class _P2>
621 _LIBCPP_INLINE_VISIBILITY
622 void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source)
623 {
624 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
625 "merging container with incompatible allocator");
626 __table_.__node_handle_merge_unique(__source.__table_);
627 }
628 template<class _H2, class _P2>
629 _LIBCPP_INLINE_VISIBILITY
630 void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source)
631 {
632 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
633 "merging container with incompatible allocator");
634 __table_.__node_handle_merge_unique(__source.__table_);
635 }
636 template<class _H2, class _P2>
637 _LIBCPP_INLINE_VISIBILITY
638 void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source)
639 {
640 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
641 "merging container with incompatible allocator");
642 __table_.__node_handle_merge_unique(__source.__table_);
643 }
644 template<class _H2, class _P2>
645 _LIBCPP_INLINE_VISIBILITY
646 void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source)
647 {
648 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
649 "merging container with incompatible allocator");
650 __table_.__node_handle_merge_unique(__source.__table_);
651 }
Erik Pilkingtonb0386a52018-08-01 01:33:38 +0000652#endif
653
Howard Hinnant789847d2010-09-23 18:58:28 +0000654 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000655 void swap(unordered_set& __u)
656 _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
657 {__table_.swap(__u.__table_);}
Howard Hinnant3e519522010-05-11 19:42:16 +0000658
Howard Hinnant789847d2010-09-23 18:58:28 +0000659 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000660 hasher hash_function() const {return __table_.hash_function();}
Howard Hinnant789847d2010-09-23 18:58:28 +0000661 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000662 key_equal key_eq() const {return __table_.key_eq();}
663
Howard Hinnant789847d2010-09-23 18:58:28 +0000664 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000665 iterator find(const key_type& __k) {return __table_.find(__k);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000666 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000667 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000668 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000669 size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000670 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000671 pair<iterator, iterator> equal_range(const key_type& __k)
672 {return __table_.__equal_range_unique(__k);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000673 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000674 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
675 {return __table_.__equal_range_unique(__k);}
676
Howard Hinnant789847d2010-09-23 18:58:28 +0000677 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000678 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
Howard Hinnant789847d2010-09-23 18:58:28 +0000679 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000680 size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
Howard Hinnant3e519522010-05-11 19:42:16 +0000681
Howard Hinnant789847d2010-09-23 18:58:28 +0000682 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000683 size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000684 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000685 size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
686
Howard Hinnant789847d2010-09-23 18:58:28 +0000687 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000688 local_iterator begin(size_type __n) {return __table_.begin(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000689 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000690 local_iterator end(size_type __n) {return __table_.end(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000691 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000692 const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000693 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000694 const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000695 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000696 const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000697 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000698 const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
699
Howard Hinnant789847d2010-09-23 18:58:28 +0000700 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000701 float load_factor() const _NOEXCEPT {return __table_.load_factor();}
Howard Hinnant789847d2010-09-23 18:58:28 +0000702 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +0000703 float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
Howard Hinnant789847d2010-09-23 18:58:28 +0000704 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000705 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000706 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000707 void rehash(size_type __n) {__table_.rehash(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +0000708 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000709 void reserve(size_type __n) {__table_.reserve(__n);}
Howard Hinnantb24c8022013-07-23 22:01:58 +0000710
711#if _LIBCPP_DEBUG_LEVEL >= 2
712
713 bool __dereferenceable(const const_iterator* __i) const
714 {return __table_.__dereferenceable(__i);}
715 bool __decrementable(const const_iterator* __i) const
716 {return __table_.__decrementable(__i);}
717 bool __addable(const const_iterator* __i, ptrdiff_t __n) const
718 {return __table_.__addable(__i, __n);}
719 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
720 {return __table_.__addable(__i, __n);}
721
722#endif // _LIBCPP_DEBUG_LEVEL >= 2
723
Howard Hinnant3e519522010-05-11 19:42:16 +0000724};
725
726template <class _Value, class _Hash, class _Pred, class _Alloc>
727unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
728 const hasher& __hf, const key_equal& __eql)
729 : __table_(__hf, __eql)
730{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000731#if _LIBCPP_DEBUG_LEVEL >= 2
732 __get_db()->__insert_c(this);
733#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000734 __table_.rehash(__n);
735}
736
737template <class _Value, class _Hash, class _Pred, class _Alloc>
738unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
739 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
740 : __table_(__hf, __eql, __a)
741{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000742#if _LIBCPP_DEBUG_LEVEL >= 2
743 __get_db()->__insert_c(this);
744#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000745 __table_.rehash(__n);
746}
747
748template <class _Value, class _Hash, class _Pred, class _Alloc>
749template <class _InputIterator>
750unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
751 _InputIterator __first, _InputIterator __last)
752{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000753#if _LIBCPP_DEBUG_LEVEL >= 2
754 __get_db()->__insert_c(this);
755#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000756 insert(__first, __last);
757}
758
759template <class _Value, class _Hash, class _Pred, class _Alloc>
760template <class _InputIterator>
761unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
762 _InputIterator __first, _InputIterator __last, size_type __n,
763 const hasher& __hf, const key_equal& __eql)
764 : __table_(__hf, __eql)
765{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000766#if _LIBCPP_DEBUG_LEVEL >= 2
767 __get_db()->__insert_c(this);
768#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000769 __table_.rehash(__n);
770 insert(__first, __last);
771}
772
773template <class _Value, class _Hash, class _Pred, class _Alloc>
774template <class _InputIterator>
775unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
776 _InputIterator __first, _InputIterator __last, size_type __n,
777 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
778 : __table_(__hf, __eql, __a)
779{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000780#if _LIBCPP_DEBUG_LEVEL >= 2
781 __get_db()->__insert_c(this);
782#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000783 __table_.rehash(__n);
784 insert(__first, __last);
785}
786
787template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +0000788inline
Howard Hinnant3e519522010-05-11 19:42:16 +0000789unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
790 const allocator_type& __a)
791 : __table_(__a)
792{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000793#if _LIBCPP_DEBUG_LEVEL >= 2
794 __get_db()->__insert_c(this);
795#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000796}
797
798template <class _Value, class _Hash, class _Pred, class _Alloc>
799unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
800 const unordered_set& __u)
801 : __table_(__u.__table_)
802{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000803#if _LIBCPP_DEBUG_LEVEL >= 2
804 __get_db()->__insert_c(this);
805#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000806 __table_.rehash(__u.bucket_count());
807 insert(__u.begin(), __u.end());
808}
809
810template <class _Value, class _Hash, class _Pred, class _Alloc>
811unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
812 const unordered_set& __u, const allocator_type& __a)
813 : __table_(__u.__table_, __a)
814{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000815#if _LIBCPP_DEBUG_LEVEL >= 2
816 __get_db()->__insert_c(this);
817#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000818 __table_.rehash(__u.bucket_count());
819 insert(__u.begin(), __u.end());
820}
821
Eric Fiselierf0f86ef2017-04-18 22:37:32 +0000822#ifndef _LIBCPP_CXX03_LANG
Howard Hinnant3e519522010-05-11 19:42:16 +0000823
824template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +0000825inline
Howard Hinnant3e519522010-05-11 19:42:16 +0000826unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
827 unordered_set&& __u)
Howard Hinnant557da862011-06-04 20:18:37 +0000828 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
Howard Hinnantce48a112011-06-30 21:18:19 +0000829 : __table_(_VSTD::move(__u.__table_))
Howard Hinnant3e519522010-05-11 19:42:16 +0000830{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000831#if _LIBCPP_DEBUG_LEVEL >= 2
832 __get_db()->__insert_c(this);
833 __get_db()->swap(this, &__u);
834#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000835}
836
837template <class _Value, class _Hash, class _Pred, class _Alloc>
838unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
839 unordered_set&& __u, const allocator_type& __a)
Howard Hinnantce48a112011-06-30 21:18:19 +0000840 : __table_(_VSTD::move(__u.__table_), __a)
Howard Hinnant3e519522010-05-11 19:42:16 +0000841{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000842#if _LIBCPP_DEBUG_LEVEL >= 2
843 __get_db()->__insert_c(this);
844#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000845 if (__a != __u.get_allocator())
846 {
847 iterator __i = __u.begin();
848 while (__u.size() != 0)
Howard Hinnantce48a112011-06-30 21:18:19 +0000849 __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
Howard Hinnant3e519522010-05-11 19:42:16 +0000850 }
Howard Hinnantb24c8022013-07-23 22:01:58 +0000851#if _LIBCPP_DEBUG_LEVEL >= 2
852 else
853 __get_db()->swap(this, &__u);
854#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000855}
856
Howard Hinnant3e519522010-05-11 19:42:16 +0000857template <class _Value, class _Hash, class _Pred, class _Alloc>
858unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
859 initializer_list<value_type> __il)
860{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000861#if _LIBCPP_DEBUG_LEVEL >= 2
862 __get_db()->__insert_c(this);
863#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000864 insert(__il.begin(), __il.end());
865}
866
867template <class _Value, class _Hash, class _Pred, class _Alloc>
868unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
869 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
870 const key_equal& __eql)
871 : __table_(__hf, __eql)
872{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000873#if _LIBCPP_DEBUG_LEVEL >= 2
874 __get_db()->__insert_c(this);
875#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000876 __table_.rehash(__n);
877 insert(__il.begin(), __il.end());
878}
879
880template <class _Value, class _Hash, class _Pred, class _Alloc>
881unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
882 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
883 const key_equal& __eql, const allocator_type& __a)
884 : __table_(__hf, __eql, __a)
885{
Howard Hinnantb24c8022013-07-23 22:01:58 +0000886#if _LIBCPP_DEBUG_LEVEL >= 2
887 __get_db()->__insert_c(this);
888#endif
Howard Hinnant3e519522010-05-11 19:42:16 +0000889 __table_.rehash(__n);
890 insert(__il.begin(), __il.end());
891}
892
Howard Hinnant3e519522010-05-11 19:42:16 +0000893template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +0000894inline
Howard Hinnant3e519522010-05-11 19:42:16 +0000895unordered_set<_Value, _Hash, _Pred, _Alloc>&
896unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
Howard Hinnant557da862011-06-04 20:18:37 +0000897 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
Howard Hinnant3e519522010-05-11 19:42:16 +0000898{
Howard Hinnantce48a112011-06-30 21:18:19 +0000899 __table_ = _VSTD::move(__u.__table_);
Howard Hinnant3e519522010-05-11 19:42:16 +0000900 return *this;
901}
902
Howard Hinnant3e519522010-05-11 19:42:16 +0000903template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +0000904inline
Howard Hinnant3e519522010-05-11 19:42:16 +0000905unordered_set<_Value, _Hash, _Pred, _Alloc>&
906unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
907 initializer_list<value_type> __il)
908{
909 __table_.__assign_unique(__il.begin(), __il.end());
910 return *this;
911}
912
Eric Fiselierf0f86ef2017-04-18 22:37:32 +0000913#endif // _LIBCPP_CXX03_LANG
Howard Hinnant54976f22011-08-12 21:56:02 +0000914
Howard Hinnant3e519522010-05-11 19:42:16 +0000915template <class _Value, class _Hash, class _Pred, class _Alloc>
916template <class _InputIterator>
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +0000917inline
Howard Hinnant3e519522010-05-11 19:42:16 +0000918void
919unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
920 _InputIterator __last)
921{
922 for (; __first != __last; ++__first)
923 __table_.__insert_unique(*__first);
924}
925
926template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnant789847d2010-09-23 18:58:28 +0000927inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000928void
929swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
930 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
Howard Hinnant557da862011-06-04 20:18:37 +0000931 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnant3e519522010-05-11 19:42:16 +0000932{
933 __x.swap(__y);
934}
935
936template <class _Value, class _Hash, class _Pred, class _Alloc>
937bool
938operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
939 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
940{
941 if (__x.size() != __y.size())
942 return false;
943 typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
944 const_iterator;
945 for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
946 __i != __ex; ++__i)
947 {
948 const_iterator __j = __y.find(*__i);
949 if (__j == __ey || !(*__i == *__j))
950 return false;
951 }
952 return true;
953}
954
955template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnant789847d2010-09-23 18:58:28 +0000956inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +0000957bool
958operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
959 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
960{
961 return !(__x == __y);
962}
963
964template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
965 class _Alloc = allocator<_Value> >
Eric Fiseliere2f2d1e2017-01-04 23:56:00 +0000966class _LIBCPP_TEMPLATE_VIS unordered_multiset
Howard Hinnant3e519522010-05-11 19:42:16 +0000967{
968public:
969 // types
970 typedef _Value key_type;
971 typedef key_type value_type;
972 typedef _Hash hasher;
973 typedef _Pred key_equal;
974 typedef _Alloc allocator_type;
975 typedef value_type& reference;
976 typedef const value_type& const_reference;
Howard Hinnantb24c8022013-07-23 22:01:58 +0000977 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
978 "Invalid allocator::value_type");
Howard Hinnant3e519522010-05-11 19:42:16 +0000979
980private:
981 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
982
983 __table __table_;
984
985public:
986 typedef typename __table::pointer pointer;
987 typedef typename __table::const_pointer const_pointer;
988 typedef typename __table::size_type size_type;
989 typedef typename __table::difference_type difference_type;
990
991 typedef typename __table::const_iterator iterator;
992 typedef typename __table::const_iterator const_iterator;
993 typedef typename __table::const_local_iterator local_iterator;
994 typedef typename __table::const_local_iterator const_local_iterator;
995
Erik Pilkingtonb0386a52018-08-01 01:33:38 +0000996#if _LIBCPP_STD_VER > 14
997 typedef __set_node_handle<typename __table::__node, allocator_type> node_type;
998#endif
999
Erik Pilkington5c4e07a2018-10-31 17:31:35 +00001000 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
1001 friend class _LIBCPP_TEMPLATE_VIS unordered_set;
1002 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
1003 friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;
1004
Howard Hinnant789847d2010-09-23 18:58:28 +00001005 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001006 unordered_multiset()
1007 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
Howard Hinnantb24c8022013-07-23 22:01:58 +00001008 {
1009#if _LIBCPP_DEBUG_LEVEL >= 2
1010 __get_db()->__insert_c(this);
1011#endif
1012 }
Howard Hinnant3e519522010-05-11 19:42:16 +00001013 explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(),
1014 const key_equal& __eql = key_equal());
1015 unordered_multiset(size_type __n, const hasher& __hf,
1016 const key_equal& __eql, const allocator_type& __a);
Marshall Clow45b983c2013-09-30 21:33:51 +00001017#if _LIBCPP_STD_VER > 11
1018 inline _LIBCPP_INLINE_VISIBILITY
1019 unordered_multiset(size_type __n, const allocator_type& __a)
1020 : unordered_multiset(__n, hasher(), key_equal(), __a) {}
1021 inline _LIBCPP_INLINE_VISIBILITY
1022 unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
1023 : unordered_multiset(__n, __hf, key_equal(), __a) {}
1024#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001025 template <class _InputIterator>
1026 unordered_multiset(_InputIterator __first, _InputIterator __last);
1027 template <class _InputIterator>
1028 unordered_multiset(_InputIterator __first, _InputIterator __last,
1029 size_type __n, const hasher& __hf = hasher(),
1030 const key_equal& __eql = key_equal());
1031 template <class _InputIterator>
1032 unordered_multiset(_InputIterator __first, _InputIterator __last,
1033 size_type __n , const hasher& __hf,
1034 const key_equal& __eql, const allocator_type& __a);
Marshall Clow45b983c2013-09-30 21:33:51 +00001035#if _LIBCPP_STD_VER > 11
1036 template <class _InputIterator>
1037 inline _LIBCPP_INLINE_VISIBILITY
1038 unordered_multiset(_InputIterator __first, _InputIterator __last,
1039 size_type __n, const allocator_type& __a)
1040 : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {}
1041 template <class _InputIterator>
1042 inline _LIBCPP_INLINE_VISIBILITY
1043 unordered_multiset(_InputIterator __first, _InputIterator __last,
1044 size_type __n, const hasher& __hf, const allocator_type& __a)
1045 : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
1046#endif
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +00001047 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001048 explicit unordered_multiset(const allocator_type& __a);
1049 unordered_multiset(const unordered_multiset& __u);
1050 unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
Eric Fiselierf0f86ef2017-04-18 22:37:32 +00001051#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +00001052 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001053 unordered_multiset(unordered_multiset&& __u)
1054 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
Howard Hinnant3e519522010-05-11 19:42:16 +00001055 unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
Howard Hinnant3e519522010-05-11 19:42:16 +00001056 unordered_multiset(initializer_list<value_type> __il);
1057 unordered_multiset(initializer_list<value_type> __il, size_type __n,
1058 const hasher& __hf = hasher(),
1059 const key_equal& __eql = key_equal());
1060 unordered_multiset(initializer_list<value_type> __il, size_type __n,
1061 const hasher& __hf, const key_equal& __eql,
1062 const allocator_type& __a);
Marshall Clow45b983c2013-09-30 21:33:51 +00001063#if _LIBCPP_STD_VER > 11
1064 inline _LIBCPP_INLINE_VISIBILITY
1065 unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
1066 : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
1067 inline _LIBCPP_INLINE_VISIBILITY
1068 unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
1069 : unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
1070#endif
Eric Fiselierf0f86ef2017-04-18 22:37:32 +00001071#endif // _LIBCPP_CXX03_LANG
Howard Hinnant3e519522010-05-11 19:42:16 +00001072 // ~unordered_multiset() = default;
Howard Hinnant5a336872011-07-01 19:24:36 +00001073 _LIBCPP_INLINE_VISIBILITY
1074 unordered_multiset& operator=(const unordered_multiset& __u)
1075 {
1076 __table_ = __u.__table_;
1077 return *this;
1078 }
Eric Fiselierf0f86ef2017-04-18 22:37:32 +00001079#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +00001080 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001081 unordered_multiset& operator=(unordered_multiset&& __u)
1082 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
Howard Hinnant3e519522010-05-11 19:42:16 +00001083 unordered_multiset& operator=(initializer_list<value_type> __il);
Eric Fiselierf0f86ef2017-04-18 22:37:32 +00001084#endif // _LIBCPP_CXX03_LANG
Howard Hinnant3e519522010-05-11 19:42:16 +00001085
Howard Hinnant789847d2010-09-23 18:58:28 +00001086 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001087 allocator_type get_allocator() const _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:16 +00001088 {return allocator_type(__table_.__node_alloc());}
1089
Marshall Clow72c8fad2017-11-15 05:51:26 +00001090 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001091 bool empty() const _NOEXCEPT {return __table_.size() == 0;}
Howard Hinnant789847d2010-09-23 18:58:28 +00001092 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001093 size_type size() const _NOEXCEPT {return __table_.size();}
Howard Hinnant789847d2010-09-23 18:58:28 +00001094 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001095 size_type max_size() const _NOEXCEPT {return __table_.max_size();}
Howard Hinnant3e519522010-05-11 19:42:16 +00001096
Howard Hinnant789847d2010-09-23 18:58:28 +00001097 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001098 iterator begin() _NOEXCEPT {return __table_.begin();}
Howard Hinnant789847d2010-09-23 18:58:28 +00001099 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001100 iterator end() _NOEXCEPT {return __table_.end();}
Howard Hinnant789847d2010-09-23 18:58:28 +00001101 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001102 const_iterator begin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnant789847d2010-09-23 18:58:28 +00001103 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001104 const_iterator end() const _NOEXCEPT {return __table_.end();}
Howard Hinnant789847d2010-09-23 18:58:28 +00001105 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001106 const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnant789847d2010-09-23 18:58:28 +00001107 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001108 const_iterator cend() const _NOEXCEPT {return __table_.end();}
Howard Hinnant3e519522010-05-11 19:42:16 +00001109
Eric Fiselierf0f86ef2017-04-18 22:37:32 +00001110#ifndef _LIBCPP_CXX03_LANG
Howard Hinnant3e519522010-05-11 19:42:16 +00001111 template <class... _Args>
Howard Hinnant789847d2010-09-23 18:58:28 +00001112 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001113 iterator emplace(_Args&&... __args)
Howard Hinnantce48a112011-06-30 21:18:19 +00001114 {return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
Howard Hinnant3e519522010-05-11 19:42:16 +00001115 template <class... _Args>
Howard Hinnant789847d2010-09-23 18:58:28 +00001116 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001117 iterator emplace_hint(const_iterator __p, _Args&&... __args)
Howard Hinnantce48a112011-06-30 21:18:19 +00001118 {return __table_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
Eric Fiselierf0f86ef2017-04-18 22:37:32 +00001119
Howard Hinnant789847d2010-09-23 18:58:28 +00001120 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantce48a112011-06-30 21:18:19 +00001121 iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
Howard Hinnant789847d2010-09-23 18:58:28 +00001122 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001123 iterator insert(const_iterator __p, value_type&& __x)
Howard Hinnantce48a112011-06-30 21:18:19 +00001124 {return __table_.__insert_multi(__p, _VSTD::move(__x));}
Howard Hinnant789847d2010-09-23 18:58:28 +00001125 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001126 void insert(initializer_list<value_type> __il)
1127 {insert(__il.begin(), __il.end());}
Eric Fiselierf0f86ef2017-04-18 22:37:32 +00001128#endif // _LIBCPP_CXX03_LANG
1129
1130 _LIBCPP_INLINE_VISIBILITY
1131 iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
1132
1133 _LIBCPP_INLINE_VISIBILITY
1134 iterator insert(const_iterator __p, const value_type& __x)
1135 {return __table_.__insert_multi(__p, __x);}
1136
1137 template <class _InputIterator>
1138 _LIBCPP_INLINE_VISIBILITY
1139 void insert(_InputIterator __first, _InputIterator __last);
Howard Hinnant3e519522010-05-11 19:42:16 +00001140
Erik Pilkingtonb0386a52018-08-01 01:33:38 +00001141#if _LIBCPP_STD_VER > 14
1142 _LIBCPP_INLINE_VISIBILITY
1143 iterator insert(node_type&& __nh)
1144 {
1145 _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1146 "node_type with incompatible allocator passed to unordered_multiset::insert()");
1147 return __table_.template __node_handle_insert_multi<node_type>(
1148 _VSTD::move(__nh));
1149 }
1150 _LIBCPP_INLINE_VISIBILITY
1151 iterator insert(const_iterator __hint, node_type&& __nh)
1152 {
1153 _LIBCPP_ASSERT(__nh.empty() || __nh.get_allocator() == get_allocator(),
1154 "node_type with incompatible allocator passed to unordered_multiset::insert()");
1155 return __table_.template __node_handle_insert_multi<node_type>(
1156 __hint, _VSTD::move(__nh));
1157 }
1158 _LIBCPP_INLINE_VISIBILITY
1159 node_type extract(const_iterator __position)
1160 {
1161 return __table_.template __node_handle_extract<node_type>(
1162 __position);
1163 }
1164 _LIBCPP_INLINE_VISIBILITY
1165 node_type extract(key_type const& __key)
1166 {
1167 return __table_.template __node_handle_extract<node_type>(__key);
1168 }
Erik Pilkington5c4e07a2018-10-31 17:31:35 +00001169
1170 template <class _H2, class _P2>
1171 _LIBCPP_INLINE_VISIBILITY
1172 void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>& __source)
1173 {
1174 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1175 "merging container with incompatible allocator");
1176 return __table_.__node_handle_merge_multi(__source.__table_);
1177 }
1178 template <class _H2, class _P2>
1179 _LIBCPP_INLINE_VISIBILITY
1180 void merge(unordered_multiset<key_type, _H2, _P2, allocator_type>&& __source)
1181 {
1182 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1183 "merging container with incompatible allocator");
1184 return __table_.__node_handle_merge_multi(__source.__table_);
1185 }
1186 template <class _H2, class _P2>
1187 _LIBCPP_INLINE_VISIBILITY
1188 void merge(unordered_set<key_type, _H2, _P2, allocator_type>& __source)
1189 {
1190 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1191 "merging container with incompatible allocator");
1192 return __table_.__node_handle_merge_multi(__source.__table_);
1193 }
1194 template <class _H2, class _P2>
1195 _LIBCPP_INLINE_VISIBILITY
1196 void merge(unordered_set<key_type, _H2, _P2, allocator_type>&& __source)
1197 {
1198 _LIBCPP_ASSERT(__source.get_allocator() == get_allocator(),
1199 "merging container with incompatible allocator");
1200 return __table_.__node_handle_merge_multi(__source.__table_);
1201 }
Erik Pilkingtonb0386a52018-08-01 01:33:38 +00001202#endif
1203
Howard Hinnant789847d2010-09-23 18:58:28 +00001204 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001205 iterator erase(const_iterator __p) {return __table_.erase(__p);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001206 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001207 size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001208 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001209 iterator erase(const_iterator __first, const_iterator __last)
1210 {return __table_.erase(__first, __last);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001211 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001212 void clear() _NOEXCEPT {__table_.clear();}
Howard Hinnant3e519522010-05-11 19:42:16 +00001213
Howard Hinnant789847d2010-09-23 18:58:28 +00001214 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001215 void swap(unordered_multiset& __u)
1216 _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
1217 {__table_.swap(__u.__table_);}
Howard Hinnant3e519522010-05-11 19:42:16 +00001218
Howard Hinnant789847d2010-09-23 18:58:28 +00001219 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001220 hasher hash_function() const {return __table_.hash_function();}
Howard Hinnant789847d2010-09-23 18:58:28 +00001221 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001222 key_equal key_eq() const {return __table_.key_eq();}
1223
Howard Hinnant789847d2010-09-23 18:58:28 +00001224 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001225 iterator find(const key_type& __k) {return __table_.find(__k);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001226 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001227 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001228 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001229 size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001230 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001231 pair<iterator, iterator> equal_range(const key_type& __k)
1232 {return __table_.__equal_range_multi(__k);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001233 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001234 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
1235 {return __table_.__equal_range_multi(__k);}
1236
Howard Hinnant789847d2010-09-23 18:58:28 +00001237 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001238 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
Howard Hinnant789847d2010-09-23 18:58:28 +00001239 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001240 size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
Howard Hinnant3e519522010-05-11 19:42:16 +00001241
Howard Hinnant789847d2010-09-23 18:58:28 +00001242 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001243 size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001244 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001245 size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
1246
Howard Hinnant789847d2010-09-23 18:58:28 +00001247 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001248 local_iterator begin(size_type __n) {return __table_.begin(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001249 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001250 local_iterator end(size_type __n) {return __table_.end(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001251 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001252 const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001253 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001254 const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001255 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001256 const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001257 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001258 const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
1259
Howard Hinnant789847d2010-09-23 18:58:28 +00001260 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001261 float load_factor() const _NOEXCEPT {return __table_.load_factor();}
Howard Hinnant789847d2010-09-23 18:58:28 +00001262 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant557da862011-06-04 20:18:37 +00001263 float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
Howard Hinnant789847d2010-09-23 18:58:28 +00001264 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001265 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001266 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001267 void rehash(size_type __n) {__table_.rehash(__n);}
Howard Hinnant789847d2010-09-23 18:58:28 +00001268 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001269 void reserve(size_type __n) {__table_.reserve(__n);}
Howard Hinnantb24c8022013-07-23 22:01:58 +00001270
1271#if _LIBCPP_DEBUG_LEVEL >= 2
1272
1273 bool __dereferenceable(const const_iterator* __i) const
1274 {return __table_.__dereferenceable(__i);}
1275 bool __decrementable(const const_iterator* __i) const
1276 {return __table_.__decrementable(__i);}
1277 bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1278 {return __table_.__addable(__i, __n);}
1279 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1280 {return __table_.__addable(__i, __n);}
1281
1282#endif // _LIBCPP_DEBUG_LEVEL >= 2
1283
Howard Hinnant3e519522010-05-11 19:42:16 +00001284};
1285
1286template <class _Value, class _Hash, class _Pred, class _Alloc>
1287unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1288 size_type __n, const hasher& __hf, const key_equal& __eql)
1289 : __table_(__hf, __eql)
1290{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001291#if _LIBCPP_DEBUG_LEVEL >= 2
1292 __get_db()->__insert_c(this);
1293#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001294 __table_.rehash(__n);
1295}
1296
1297template <class _Value, class _Hash, class _Pred, class _Alloc>
1298unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1299 size_type __n, const hasher& __hf, const key_equal& __eql,
1300 const allocator_type& __a)
1301 : __table_(__hf, __eql, __a)
1302{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001303#if _LIBCPP_DEBUG_LEVEL >= 2
1304 __get_db()->__insert_c(this);
1305#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001306 __table_.rehash(__n);
1307}
1308
1309template <class _Value, class _Hash, class _Pred, class _Alloc>
1310template <class _InputIterator>
1311unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1312 _InputIterator __first, _InputIterator __last)
1313{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001314#if _LIBCPP_DEBUG_LEVEL >= 2
1315 __get_db()->__insert_c(this);
1316#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001317 insert(__first, __last);
1318}
1319
1320template <class _Value, class _Hash, class _Pred, class _Alloc>
1321template <class _InputIterator>
1322unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1323 _InputIterator __first, _InputIterator __last, size_type __n,
1324 const hasher& __hf, const key_equal& __eql)
1325 : __table_(__hf, __eql)
1326{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001327#if _LIBCPP_DEBUG_LEVEL >= 2
1328 __get_db()->__insert_c(this);
1329#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001330 __table_.rehash(__n);
1331 insert(__first, __last);
1332}
1333
1334template <class _Value, class _Hash, class _Pred, class _Alloc>
1335template <class _InputIterator>
1336unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1337 _InputIterator __first, _InputIterator __last, size_type __n,
1338 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1339 : __table_(__hf, __eql, __a)
1340{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001341#if _LIBCPP_DEBUG_LEVEL >= 2
1342 __get_db()->__insert_c(this);
1343#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001344 __table_.rehash(__n);
1345 insert(__first, __last);
1346}
1347
1348template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +00001349inline
Howard Hinnant3e519522010-05-11 19:42:16 +00001350unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1351 const allocator_type& __a)
1352 : __table_(__a)
1353{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001354#if _LIBCPP_DEBUG_LEVEL >= 2
1355 __get_db()->__insert_c(this);
1356#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001357}
1358
1359template <class _Value, class _Hash, class _Pred, class _Alloc>
1360unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1361 const unordered_multiset& __u)
1362 : __table_(__u.__table_)
1363{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001364#if _LIBCPP_DEBUG_LEVEL >= 2
1365 __get_db()->__insert_c(this);
1366#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001367 __table_.rehash(__u.bucket_count());
1368 insert(__u.begin(), __u.end());
1369}
1370
1371template <class _Value, class _Hash, class _Pred, class _Alloc>
1372unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1373 const unordered_multiset& __u, const allocator_type& __a)
1374 : __table_(__u.__table_, __a)
1375{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001376#if _LIBCPP_DEBUG_LEVEL >= 2
1377 __get_db()->__insert_c(this);
1378#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001379 __table_.rehash(__u.bucket_count());
1380 insert(__u.begin(), __u.end());
1381}
1382
Eric Fiselierf0f86ef2017-04-18 22:37:32 +00001383#ifndef _LIBCPP_CXX03_LANG
Howard Hinnant3e519522010-05-11 19:42:16 +00001384
1385template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +00001386inline
Howard Hinnant3e519522010-05-11 19:42:16 +00001387unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1388 unordered_multiset&& __u)
Howard Hinnant557da862011-06-04 20:18:37 +00001389 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
Howard Hinnantce48a112011-06-30 21:18:19 +00001390 : __table_(_VSTD::move(__u.__table_))
Howard Hinnant3e519522010-05-11 19:42:16 +00001391{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001392#if _LIBCPP_DEBUG_LEVEL >= 2
1393 __get_db()->__insert_c(this);
1394 __get_db()->swap(this, &__u);
1395#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001396}
1397
1398template <class _Value, class _Hash, class _Pred, class _Alloc>
1399unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1400 unordered_multiset&& __u, const allocator_type& __a)
Howard Hinnantce48a112011-06-30 21:18:19 +00001401 : __table_(_VSTD::move(__u.__table_), __a)
Howard Hinnant3e519522010-05-11 19:42:16 +00001402{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001403#if _LIBCPP_DEBUG_LEVEL >= 2
1404 __get_db()->__insert_c(this);
1405#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001406 if (__a != __u.get_allocator())
1407 {
1408 iterator __i = __u.begin();
1409 while (__u.size() != 0)
Howard Hinnantce48a112011-06-30 21:18:19 +00001410 __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
Howard Hinnant3e519522010-05-11 19:42:16 +00001411 }
Howard Hinnantb24c8022013-07-23 22:01:58 +00001412#if _LIBCPP_DEBUG_LEVEL >= 2
1413 else
1414 __get_db()->swap(this, &__u);
1415#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001416}
1417
Howard Hinnant3e519522010-05-11 19:42:16 +00001418template <class _Value, class _Hash, class _Pred, class _Alloc>
1419unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1420 initializer_list<value_type> __il)
1421{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001422#if _LIBCPP_DEBUG_LEVEL >= 2
1423 __get_db()->__insert_c(this);
1424#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001425 insert(__il.begin(), __il.end());
1426}
1427
1428template <class _Value, class _Hash, class _Pred, class _Alloc>
1429unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1430 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1431 const key_equal& __eql)
1432 : __table_(__hf, __eql)
1433{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001434#if _LIBCPP_DEBUG_LEVEL >= 2
1435 __get_db()->__insert_c(this);
1436#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001437 __table_.rehash(__n);
1438 insert(__il.begin(), __il.end());
1439}
1440
1441template <class _Value, class _Hash, class _Pred, class _Alloc>
1442unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1443 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1444 const key_equal& __eql, const allocator_type& __a)
1445 : __table_(__hf, __eql, __a)
1446{
Howard Hinnantb24c8022013-07-23 22:01:58 +00001447#if _LIBCPP_DEBUG_LEVEL >= 2
1448 __get_db()->__insert_c(this);
1449#endif
Howard Hinnant3e519522010-05-11 19:42:16 +00001450 __table_.rehash(__n);
1451 insert(__il.begin(), __il.end());
1452}
1453
Howard Hinnant3e519522010-05-11 19:42:16 +00001454template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +00001455inline
Howard Hinnant3e519522010-05-11 19:42:16 +00001456unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1457unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
1458 unordered_multiset&& __u)
Howard Hinnant557da862011-06-04 20:18:37 +00001459 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
Howard Hinnant3e519522010-05-11 19:42:16 +00001460{
Howard Hinnantce48a112011-06-30 21:18:19 +00001461 __table_ = _VSTD::move(__u.__table_);
Howard Hinnant3e519522010-05-11 19:42:16 +00001462 return *this;
1463}
1464
Howard Hinnant3e519522010-05-11 19:42:16 +00001465template <class _Value, class _Hash, class _Pred, class _Alloc>
1466inline
1467unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1468unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
1469 initializer_list<value_type> __il)
1470{
1471 __table_.__assign_multi(__il.begin(), __il.end());
1472 return *this;
1473}
1474
Eric Fiselierf0f86ef2017-04-18 22:37:32 +00001475#endif // _LIBCPP_CXX03_LANG
Howard Hinnant54976f22011-08-12 21:56:02 +00001476
Howard Hinnant3e519522010-05-11 19:42:16 +00001477template <class _Value, class _Hash, class _Pred, class _Alloc>
1478template <class _InputIterator>
Evgeniy Stepanovcd31b432016-04-22 01:04:55 +00001479inline
Howard Hinnant3e519522010-05-11 19:42:16 +00001480void
1481unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
1482 _InputIterator __last)
1483{
1484 for (; __first != __last; ++__first)
1485 __table_.__insert_multi(*__first);
1486}
1487
1488template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnant789847d2010-09-23 18:58:28 +00001489inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001490void
1491swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1492 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
Howard Hinnant557da862011-06-04 20:18:37 +00001493 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnant3e519522010-05-11 19:42:16 +00001494{
1495 __x.swap(__y);
1496}
1497
1498template <class _Value, class _Hash, class _Pred, class _Alloc>
1499bool
1500operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1501 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1502{
1503 if (__x.size() != __y.size())
1504 return false;
1505 typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
1506 const_iterator;
1507 typedef pair<const_iterator, const_iterator> _EqRng;
1508 for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
1509 {
1510 _EqRng __xeq = __x.equal_range(*__i);
1511 _EqRng __yeq = __y.equal_range(*__i);
Howard Hinnantce48a112011-06-30 21:18:19 +00001512 if (_VSTD::distance(__xeq.first, __xeq.second) !=
1513 _VSTD::distance(__yeq.first, __yeq.second) ||
1514 !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
Howard Hinnant3e519522010-05-11 19:42:16 +00001515 return false;
1516 __i = __xeq.second;
1517 }
1518 return true;
1519}
1520
1521template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnant789847d2010-09-23 18:58:28 +00001522inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnant3e519522010-05-11 19:42:16 +00001523bool
1524operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1525 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1526{
1527 return !(__x == __y);
1528}
1529
1530_LIBCPP_END_NAMESPACE_STD
1531
1532#endif // _LIBCPP_UNORDERED_SET