blob: d7615fa05c5f8f2fa14efd6ba38bc2b55cdb2239 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===-------------------------- unordered_set -----------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-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 Hinnantbc8d3f92010-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
Howard Hinnant04dae1d2011-06-04 20:18:37 +000046 unordered_set()
47 noexcept(
48 is_nothrow_default_constructible<hasher>::value &&
49 is_nothrow_default_constructible<key_equal>::value &&
50 is_nothrow_default_constructible<allocator_type>::value);
51 explicit unordered_set(size_type n, const hasher& hf = hasher(),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000052 const key_equal& eql = key_equal(),
53 const allocator_type& a = allocator_type());
54 template <class InputIterator>
55 unordered_set(InputIterator f, InputIterator l,
56 size_type n = 0, const hasher& hf = hasher(),
57 const key_equal& eql = key_equal(),
58 const allocator_type& a = allocator_type());
59 explicit unordered_set(const allocator_type&);
60 unordered_set(const unordered_set&);
61 unordered_set(const unordered_set&, const Allocator&);
Howard Hinnant04dae1d2011-06-04 20:18:37 +000062 unordered_set(unordered_set&&)
63 noexcept(
64 is_nothrow_move_constructible<hasher>::value &&
65 is_nothrow_move_constructible<key_equal>::value &&
66 is_nothrow_move_constructible<allocator_type>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000067 unordered_set(unordered_set&&, const Allocator&);
68 unordered_set(initializer_list<value_type>, size_type n = 0,
69 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
70 const allocator_type& a = allocator_type());
71 ~unordered_set();
72 unordered_set& operator=(const unordered_set&);
Howard Hinnant04dae1d2011-06-04 20:18:37 +000073 unordered_set& operator=(unordered_set&&)
74 noexcept(
75 allocator_type::propagate_on_container_move_assignment::value &&
76 is_nothrow_move_assignable<allocator_type>::value &&
77 is_nothrow_move_assignable<hasher>::value &&
78 is_nothrow_move_assignable<key_equal>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000079 unordered_set& operator=(initializer_list<value_type>);
80
Howard Hinnant04dae1d2011-06-04 20:18:37 +000081 allocator_type get_allocator() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000082
Howard Hinnant04dae1d2011-06-04 20:18:37 +000083 bool empty() const noexcept;
84 size_type size() const noexcept;
85 size_type max_size() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000086
Howard Hinnant04dae1d2011-06-04 20:18:37 +000087 iterator begin() noexcept;
88 iterator end() noexcept;
89 const_iterator begin() const noexcept;
90 const_iterator end() const noexcept;
91 const_iterator cbegin() const noexcept;
92 const_iterator cend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000093
94 template <class... Args>
95 pair<iterator, bool> emplace(Args&&... args);
96 template <class... Args>
97 iterator emplace_hint(const_iterator position, Args&&... args);
98 pair<iterator, bool> insert(const value_type& obj);
99 pair<iterator, bool> insert(value_type&& obj);
100 iterator insert(const_iterator hint, const value_type& obj);
101 iterator insert(const_iterator hint, value_type&& obj);
102 template <class InputIterator>
103 void insert(InputIterator first, InputIterator last);
104 void insert(initializer_list<value_type>);
105
106 iterator erase(const_iterator position);
107 size_type erase(const key_type& k);
108 iterator erase(const_iterator first, const_iterator last);
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000109 void clear() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000110
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000111 void swap(unordered_set&)
112 noexcept(
113 (!allocator_type::propagate_on_container_swap::value ||
114 __is_nothrow_swappable<allocator_type>::value) &&
115 __is_nothrow_swappable<hasher>::value &&
116 __is_nothrow_swappable<key_equal>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000117
118 hasher hash_function() const;
119 key_equal key_eq() const;
120
121 iterator find(const key_type& k);
122 const_iterator find(const key_type& k) const;
123 size_type count(const key_type& k) const;
124 pair<iterator, iterator> equal_range(const key_type& k);
125 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
126
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000127 size_type bucket_count() const noexcept;
128 size_type max_bucket_count() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000129
130 size_type bucket_size(size_type n) const;
131 size_type bucket(const key_type& k) const;
132
133 local_iterator begin(size_type n);
134 local_iterator end(size_type n);
135 const_local_iterator begin(size_type n) const;
136 const_local_iterator end(size_type n) const;
137 const_local_iterator cbegin(size_type n) const;
138 const_local_iterator cend(size_type n) const;
139
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000140 float load_factor() const noexcept;
141 float max_load_factor() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000142 void max_load_factor(float z);
143 void rehash(size_type n);
144 void reserve(size_type n);
145};
146
147template <class Value, class Hash, class Pred, class Alloc>
148 void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000149 unordered_set<Value, Hash, Pred, Alloc>& y)
150 noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000151
152template <class Value, class Hash, class Pred, class Alloc>
153 bool
154 operator==(const unordered_set<Value, Hash, Pred, Alloc>& x,
155 const unordered_set<Value, Hash, Pred, Alloc>& y);
156
157template <class Value, class Hash, class Pred, class Alloc>
158 bool
159 operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x,
160 const unordered_set<Value, Hash, Pred, Alloc>& y);
161
162template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
163 class Alloc = allocator<Value>>
164class unordered_multiset
165{
166public:
167 // types
168 typedef Value key_type;
169 typedef key_type value_type;
170 typedef Hash hasher;
171 typedef Pred key_equal;
172 typedef Alloc allocator_type;
173 typedef value_type& reference;
174 typedef const value_type& const_reference;
175 typedef typename allocator_traits<allocator_type>::pointer pointer;
176 typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
177 typedef typename allocator_traits<allocator_type>::size_type size_type;
178 typedef typename allocator_traits<allocator_type>::difference_type difference_type;
179
180 typedef /unspecified/ iterator;
181 typedef /unspecified/ const_iterator;
182 typedef /unspecified/ local_iterator;
183 typedef /unspecified/ const_local_iterator;
184
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000185 unordered_multiset()
186 noexcept(
187 is_nothrow_default_constructible<hasher>::value &&
188 is_nothrow_default_constructible<key_equal>::value &&
189 is_nothrow_default_constructible<allocator_type>::value);
190 explicit unordered_multiset(size_type n, const hasher& hf = hasher(),
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000191 const key_equal& eql = key_equal(),
192 const allocator_type& a = allocator_type());
193 template <class InputIterator>
194 unordered_multiset(InputIterator f, InputIterator l,
195 size_type n = 0, const hasher& hf = hasher(),
196 const key_equal& eql = key_equal(),
197 const allocator_type& a = allocator_type());
198 explicit unordered_multiset(const allocator_type&);
199 unordered_multiset(const unordered_multiset&);
200 unordered_multiset(const unordered_multiset&, const Allocator&);
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000201 unordered_multiset(unordered_multiset&&)
202 noexcept(
203 is_nothrow_move_constructible<hasher>::value &&
204 is_nothrow_move_constructible<key_equal>::value &&
205 is_nothrow_move_constructible<allocator_type>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000206 unordered_multiset(unordered_multiset&&, const Allocator&);
207 unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
208 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
209 const allocator_type& a = allocator_type());
210 ~unordered_multiset();
211 unordered_multiset& operator=(const unordered_multiset&);
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000212 unordered_multiset& operator=(unordered_multiset&&)
213 noexcept(
214 allocator_type::propagate_on_container_move_assignment::value &&
215 is_nothrow_move_assignable<allocator_type>::value &&
216 is_nothrow_move_assignable<hasher>::value &&
217 is_nothrow_move_assignable<key_equal>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000218 unordered_multiset& operator=(initializer_list<value_type>);
219
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000220 allocator_type get_allocator() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000221
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000222 bool empty() const noexcept;
223 size_type size() const noexcept;
224 size_type max_size() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000225
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000226 iterator begin() noexcept;
227 iterator end() noexcept;
228 const_iterator begin() const noexcept;
229 const_iterator end() const noexcept;
230 const_iterator cbegin() const noexcept;
231 const_iterator cend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000232
233 template <class... Args>
234 iterator emplace(Args&&... args);
235 template <class... Args>
236 iterator emplace_hint(const_iterator position, Args&&... args);
237 iterator insert(const value_type& obj);
238 iterator insert(value_type&& obj);
239 iterator insert(const_iterator hint, const value_type& obj);
240 iterator insert(const_iterator hint, value_type&& obj);
241 template <class InputIterator>
242 void insert(InputIterator first, InputIterator last);
243 void insert(initializer_list<value_type>);
244
245 iterator erase(const_iterator position);
246 size_type erase(const key_type& k);
247 iterator erase(const_iterator first, const_iterator last);
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000248 void clear() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000249
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000250 void swap(unordered_multiset&)
251 noexcept(
252 (!allocator_type::propagate_on_container_swap::value ||
253 __is_nothrow_swappable<allocator_type>::value) &&
254 __is_nothrow_swappable<hasher>::value &&
255 __is_nothrow_swappable<key_equal>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000256
257 hasher hash_function() const;
258 key_equal key_eq() const;
259
260 iterator find(const key_type& k);
261 const_iterator find(const key_type& k) const;
262 size_type count(const key_type& k) const;
263 pair<iterator, iterator> equal_range(const key_type& k);
264 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
265
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000266 size_type bucket_count() const noexcept;
267 size_type max_bucket_count() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000268
269 size_type bucket_size(size_type n) const;
270 size_type bucket(const key_type& k) const;
271
272 local_iterator begin(size_type n);
273 local_iterator end(size_type n);
274 const_local_iterator begin(size_type n) const;
275 const_local_iterator end(size_type n) const;
276 const_local_iterator cbegin(size_type n) const;
277 const_local_iterator cend(size_type n) const;
278
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000279 float load_factor() const noexcept;
280 float max_load_factor() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000281 void max_load_factor(float z);
282 void rehash(size_type n);
283 void reserve(size_type n);
284};
285
286template <class Value, class Hash, class Pred, class Alloc>
287 void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000288 unordered_multiset<Value, Hash, Pred, Alloc>& y)
289 noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000290
291template <class Value, class Hash, class Pred, class Alloc>
292 bool
293 operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
294 const unordered_multiset<Value, Hash, Pred, Alloc>& y);
295
296template <class Value, class Hash, class Pred, class Alloc>
297 bool
298 operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
299 const unordered_multiset<Value, Hash, Pred, Alloc>& y);
300} // std
301
302*/
303
304#include <__config>
305#include <__hash_table>
306#include <functional>
307
308#pragma GCC system_header
309
310_LIBCPP_BEGIN_NAMESPACE_STD
311
312template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
313 class _Alloc = allocator<_Value> >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000314class _LIBCPP_VISIBLE unordered_set
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000315{
316public:
317 // types
318 typedef _Value key_type;
319 typedef key_type value_type;
320 typedef _Hash hasher;
321 typedef _Pred key_equal;
322 typedef _Alloc allocator_type;
323 typedef value_type& reference;
324 typedef const value_type& const_reference;
325
326private:
327 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
328
329 __table __table_;
330
331public:
332 typedef typename __table::pointer pointer;
333 typedef typename __table::const_pointer const_pointer;
334 typedef typename __table::size_type size_type;
335 typedef typename __table::difference_type difference_type;
336
337 typedef typename __table::const_iterator iterator;
338 typedef typename __table::const_iterator const_iterator;
339 typedef typename __table::const_local_iterator local_iterator;
340 typedef typename __table::const_local_iterator const_local_iterator;
341
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000342 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000343 unordered_set()
344 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
345 {} // = default;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000346 explicit unordered_set(size_type __n, const hasher& __hf = hasher(),
347 const key_equal& __eql = key_equal());
348 unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql,
349 const allocator_type& __a);
350 template <class _InputIterator>
351 unordered_set(_InputIterator __first, _InputIterator __last);
352 template <class _InputIterator>
353 unordered_set(_InputIterator __first, _InputIterator __last,
354 size_type __n, const hasher& __hf = hasher(),
355 const key_equal& __eql = key_equal());
356 template <class _InputIterator>
357 unordered_set(_InputIterator __first, _InputIterator __last,
358 size_type __n, const hasher& __hf, const key_equal& __eql,
359 const allocator_type& __a);
360 explicit unordered_set(const allocator_type& __a);
361 unordered_set(const unordered_set& __u);
362 unordered_set(const unordered_set& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19 +0000363#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000364 unordered_set(unordered_set&& __u)
365 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000366 unordered_set(unordered_set&& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19 +0000367#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnante3e32912011-08-12 21:56:02 +0000368#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000369 unordered_set(initializer_list<value_type> __il);
370 unordered_set(initializer_list<value_type> __il, size_type __n,
371 const hasher& __hf = hasher(),
372 const key_equal& __eql = key_equal());
373 unordered_set(initializer_list<value_type> __il, size_type __n,
374 const hasher& __hf, const key_equal& __eql,
375 const allocator_type& __a);
Howard Hinnante3e32912011-08-12 21:56:02 +0000376#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000377 // ~unordered_set() = default;
Howard Hinnant61aa6012011-07-01 19:24:36 +0000378 _LIBCPP_INLINE_VISIBILITY
379 unordered_set& operator=(const unordered_set& __u)
380 {
381 __table_ = __u.__table_;
382 return *this;
383 }
Howard Hinnant73d21a42010-09-04 23:28:19 +0000384#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000385 unordered_set& operator=(unordered_set&& __u)
386 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000387#endif
Howard Hinnante3e32912011-08-12 21:56:02 +0000388#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000389 unordered_set& operator=(initializer_list<value_type> __il);
Howard Hinnante3e32912011-08-12 21:56:02 +0000390#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000391
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000392 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000393 allocator_type get_allocator() const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000394 {return allocator_type(__table_.__node_alloc());}
395
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000396 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000397 bool empty() const _NOEXCEPT {return __table_.size() == 0;}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000398 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000399 size_type size() const _NOEXCEPT {return __table_.size();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000400 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000401 size_type max_size() const _NOEXCEPT {return __table_.max_size();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000402
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000403 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000404 iterator begin() _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000405 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000406 iterator end() _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000407 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000408 const_iterator begin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000409 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000410 const_iterator end() const _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000411 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000412 const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000413 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000414 const_iterator cend() const _NOEXCEPT {return __table_.end();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000415
Howard Hinnant73d21a42010-09-04 23:28:19 +0000416#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000417 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000418 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000419 pair<iterator, bool> emplace(_Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000420 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000421 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000422 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000423 iterator emplace_hint(const_iterator, _Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000424 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000425#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000426 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000427 pair<iterator, bool> insert(const value_type& __x)
428 {return __table_.__insert_unique(__x);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000429#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000430 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000431 pair<iterator, bool> insert(value_type&& __x)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000432 {return __table_.__insert_unique(_VSTD::move(__x));}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000433#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000434 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000435 iterator insert(const_iterator, const value_type& __x)
436 {return insert(__x).first;}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000437#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000438 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000439 iterator insert(const_iterator, value_type&& __x)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000440 {return insert(_VSTD::move(__x)).first;}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000441#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000442 template <class _InputIterator>
443 void insert(_InputIterator __first, _InputIterator __last);
Howard Hinnante3e32912011-08-12 21:56:02 +0000444#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000445 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000446 void insert(initializer_list<value_type> __il)
447 {insert(__il.begin(), __il.end());}
Howard Hinnante3e32912011-08-12 21:56:02 +0000448#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000449
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000450 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000451 iterator erase(const_iterator __p) {return __table_.erase(__p);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000452 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000453 size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000454 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000455 iterator erase(const_iterator __first, const_iterator __last)
456 {return __table_.erase(__first, __last);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000457 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000458 void clear() _NOEXCEPT {__table_.clear();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000459
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000460 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000461 void swap(unordered_set& __u)
462 _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
463 {__table_.swap(__u.__table_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000464
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000465 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000466 hasher hash_function() const {return __table_.hash_function();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000467 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000468 key_equal key_eq() const {return __table_.key_eq();}
469
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000470 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000471 iterator find(const key_type& __k) {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000472 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000473 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000474 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000475 size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000476 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000477 pair<iterator, iterator> equal_range(const key_type& __k)
478 {return __table_.__equal_range_unique(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000479 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000480 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
481 {return __table_.__equal_range_unique(__k);}
482
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000483 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000484 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000485 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000486 size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000487
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000488 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000489 size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000490 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000491 size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
492
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000493 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000494 local_iterator begin(size_type __n) {return __table_.begin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000495 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000496 local_iterator end(size_type __n) {return __table_.end(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000497 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000498 const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000499 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000500 const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000501 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000502 const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000503 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000504 const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
505
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000506 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000507 float load_factor() const _NOEXCEPT {return __table_.load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000508 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000509 float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000510 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000511 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000512 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000513 void rehash(size_type __n) {__table_.rehash(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000514 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000515 void reserve(size_type __n) {__table_.reserve(__n);}
516};
517
518template <class _Value, class _Hash, class _Pred, class _Alloc>
519unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
520 const hasher& __hf, const key_equal& __eql)
521 : __table_(__hf, __eql)
522{
523 __table_.rehash(__n);
524}
525
526template <class _Value, class _Hash, class _Pred, class _Alloc>
527unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
528 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
529 : __table_(__hf, __eql, __a)
530{
531 __table_.rehash(__n);
532}
533
534template <class _Value, class _Hash, class _Pred, class _Alloc>
535template <class _InputIterator>
536unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
537 _InputIterator __first, _InputIterator __last)
538{
539 insert(__first, __last);
540}
541
542template <class _Value, class _Hash, class _Pred, class _Alloc>
543template <class _InputIterator>
544unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
545 _InputIterator __first, _InputIterator __last, size_type __n,
546 const hasher& __hf, const key_equal& __eql)
547 : __table_(__hf, __eql)
548{
549 __table_.rehash(__n);
550 insert(__first, __last);
551}
552
553template <class _Value, class _Hash, class _Pred, class _Alloc>
554template <class _InputIterator>
555unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
556 _InputIterator __first, _InputIterator __last, size_type __n,
557 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
558 : __table_(__hf, __eql, __a)
559{
560 __table_.rehash(__n);
561 insert(__first, __last);
562}
563
564template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000565inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000566unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
567 const allocator_type& __a)
568 : __table_(__a)
569{
570}
571
572template <class _Value, class _Hash, class _Pred, class _Alloc>
573unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
574 const unordered_set& __u)
575 : __table_(__u.__table_)
576{
577 __table_.rehash(__u.bucket_count());
578 insert(__u.begin(), __u.end());
579}
580
581template <class _Value, class _Hash, class _Pred, class _Alloc>
582unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
583 const unordered_set& __u, const allocator_type& __a)
584 : __table_(__u.__table_, __a)
585{
586 __table_.rehash(__u.bucket_count());
587 insert(__u.begin(), __u.end());
588}
589
Howard Hinnant73d21a42010-09-04 23:28:19 +0000590#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000591
592template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000593inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000594unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
595 unordered_set&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000596 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000597 : __table_(_VSTD::move(__u.__table_))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000598{
599}
600
601template <class _Value, class _Hash, class _Pred, class _Alloc>
602unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
603 unordered_set&& __u, const allocator_type& __a)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000604 : __table_(_VSTD::move(__u.__table_), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000605{
606 if (__a != __u.get_allocator())
607 {
608 iterator __i = __u.begin();
609 while (__u.size() != 0)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000610 __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000611 }
612}
613
Howard Hinnant73d21a42010-09-04 23:28:19 +0000614#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000615
Howard Hinnante3e32912011-08-12 21:56:02 +0000616#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
617
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000618template <class _Value, class _Hash, class _Pred, class _Alloc>
619unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
620 initializer_list<value_type> __il)
621{
622 insert(__il.begin(), __il.end());
623}
624
625template <class _Value, class _Hash, class _Pred, class _Alloc>
626unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
627 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
628 const key_equal& __eql)
629 : __table_(__hf, __eql)
630{
631 __table_.rehash(__n);
632 insert(__il.begin(), __il.end());
633}
634
635template <class _Value, class _Hash, class _Pred, class _Alloc>
636unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
637 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
638 const key_equal& __eql, const allocator_type& __a)
639 : __table_(__hf, __eql, __a)
640{
641 __table_.rehash(__n);
642 insert(__il.begin(), __il.end());
643}
644
Howard Hinnante3e32912011-08-12 21:56:02 +0000645#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
646
Howard Hinnant73d21a42010-09-04 23:28:19 +0000647#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000648
649template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000650inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000651unordered_set<_Value, _Hash, _Pred, _Alloc>&
652unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000653 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000654{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000655 __table_ = _VSTD::move(__u.__table_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000656 return *this;
657}
658
Howard Hinnant73d21a42010-09-04 23:28:19 +0000659#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000660
Howard Hinnante3e32912011-08-12 21:56:02 +0000661#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
662
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000663template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000664inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000665unordered_set<_Value, _Hash, _Pred, _Alloc>&
666unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
667 initializer_list<value_type> __il)
668{
669 __table_.__assign_unique(__il.begin(), __il.end());
670 return *this;
671}
672
Howard Hinnante3e32912011-08-12 21:56:02 +0000673#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
674
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000675template <class _Value, class _Hash, class _Pred, class _Alloc>
676template <class _InputIterator>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000677inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000678void
679unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
680 _InputIterator __last)
681{
682 for (; __first != __last; ++__first)
683 __table_.__insert_unique(*__first);
684}
685
686template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000687inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000688void
689swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
690 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000691 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000692{
693 __x.swap(__y);
694}
695
696template <class _Value, class _Hash, class _Pred, class _Alloc>
697bool
698operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
699 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
700{
701 if (__x.size() != __y.size())
702 return false;
703 typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
704 const_iterator;
705 for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
706 __i != __ex; ++__i)
707 {
708 const_iterator __j = __y.find(*__i);
709 if (__j == __ey || !(*__i == *__j))
710 return false;
711 }
712 return true;
713}
714
715template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000716inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000717bool
718operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
719 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
720{
721 return !(__x == __y);
722}
723
724template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
725 class _Alloc = allocator<_Value> >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000726class _LIBCPP_VISIBLE unordered_multiset
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000727{
728public:
729 // types
730 typedef _Value key_type;
731 typedef key_type value_type;
732 typedef _Hash hasher;
733 typedef _Pred key_equal;
734 typedef _Alloc allocator_type;
735 typedef value_type& reference;
736 typedef const value_type& const_reference;
737
738private:
739 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
740
741 __table __table_;
742
743public:
744 typedef typename __table::pointer pointer;
745 typedef typename __table::const_pointer const_pointer;
746 typedef typename __table::size_type size_type;
747 typedef typename __table::difference_type difference_type;
748
749 typedef typename __table::const_iterator iterator;
750 typedef typename __table::const_iterator const_iterator;
751 typedef typename __table::const_local_iterator local_iterator;
752 typedef typename __table::const_local_iterator const_local_iterator;
753
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000754 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000755 unordered_multiset()
756 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
757 {} // = default
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000758 explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(),
759 const key_equal& __eql = key_equal());
760 unordered_multiset(size_type __n, const hasher& __hf,
761 const key_equal& __eql, const allocator_type& __a);
762 template <class _InputIterator>
763 unordered_multiset(_InputIterator __first, _InputIterator __last);
764 template <class _InputIterator>
765 unordered_multiset(_InputIterator __first, _InputIterator __last,
766 size_type __n, const hasher& __hf = hasher(),
767 const key_equal& __eql = key_equal());
768 template <class _InputIterator>
769 unordered_multiset(_InputIterator __first, _InputIterator __last,
770 size_type __n , const hasher& __hf,
771 const key_equal& __eql, const allocator_type& __a);
772 explicit unordered_multiset(const allocator_type& __a);
773 unordered_multiset(const unordered_multiset& __u);
774 unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19 +0000775#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000776 unordered_multiset(unordered_multiset&& __u)
777 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000778 unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19 +0000779#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnante3e32912011-08-12 21:56:02 +0000780#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000781 unordered_multiset(initializer_list<value_type> __il);
782 unordered_multiset(initializer_list<value_type> __il, size_type __n,
783 const hasher& __hf = hasher(),
784 const key_equal& __eql = key_equal());
785 unordered_multiset(initializer_list<value_type> __il, size_type __n,
786 const hasher& __hf, const key_equal& __eql,
787 const allocator_type& __a);
Howard Hinnante3e32912011-08-12 21:56:02 +0000788#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000789 // ~unordered_multiset() = default;
Howard Hinnant61aa6012011-07-01 19:24:36 +0000790 _LIBCPP_INLINE_VISIBILITY
791 unordered_multiset& operator=(const unordered_multiset& __u)
792 {
793 __table_ = __u.__table_;
794 return *this;
795 }
Howard Hinnant73d21a42010-09-04 23:28:19 +0000796#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000797 unordered_multiset& operator=(unordered_multiset&& __u)
798 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000799#endif
Howard Hinnante3e32912011-08-12 21:56:02 +0000800#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000801 unordered_multiset& operator=(initializer_list<value_type> __il);
Howard Hinnante3e32912011-08-12 21:56:02 +0000802#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000803
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000804 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000805 allocator_type get_allocator() const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000806 {return allocator_type(__table_.__node_alloc());}
807
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000808 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000809 bool empty() const _NOEXCEPT {return __table_.size() == 0;}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000810 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000811 size_type size() const _NOEXCEPT {return __table_.size();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000812 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000813 size_type max_size() const _NOEXCEPT {return __table_.max_size();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000814
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000815 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000816 iterator begin() _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000817 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000818 iterator end() _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000819 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000820 const_iterator begin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000821 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000822 const_iterator end() const _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000823 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000824 const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000825 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000826 const_iterator cend() const _NOEXCEPT {return __table_.end();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000827
Howard Hinnant73d21a42010-09-04 23:28:19 +0000828#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000829 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000830 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000831 iterator emplace(_Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000832 {return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000833 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000834 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000835 iterator emplace_hint(const_iterator __p, _Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000836 {return __table_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000837#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000838 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000839 iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000840#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000841 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant0949eed2011-06-30 21:18:19 +0000842 iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000843#endif
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000844 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000845 iterator insert(const_iterator __p, const value_type& __x)
846 {return __table_.__insert_multi(__p, __x);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000847#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000848 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000849 iterator insert(const_iterator __p, value_type&& __x)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000850 {return __table_.__insert_multi(__p, _VSTD::move(__x));}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000851#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000852 template <class _InputIterator>
853 void insert(_InputIterator __first, _InputIterator __last);
Howard Hinnante3e32912011-08-12 21:56:02 +0000854#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000855 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000856 void insert(initializer_list<value_type> __il)
857 {insert(__il.begin(), __il.end());}
Howard Hinnante3e32912011-08-12 21:56:02 +0000858#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000859
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000860 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000861 iterator erase(const_iterator __p) {return __table_.erase(__p);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000862 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000863 size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000864 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000865 iterator erase(const_iterator __first, const_iterator __last)
866 {return __table_.erase(__first, __last);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000867 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000868 void clear() _NOEXCEPT {__table_.clear();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000869
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000870 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000871 void swap(unordered_multiset& __u)
872 _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
873 {__table_.swap(__u.__table_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000874
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000875 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000876 hasher hash_function() const {return __table_.hash_function();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000877 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000878 key_equal key_eq() const {return __table_.key_eq();}
879
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000880 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000881 iterator find(const key_type& __k) {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000882 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000883 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000884 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000885 size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000886 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000887 pair<iterator, iterator> equal_range(const key_type& __k)
888 {return __table_.__equal_range_multi(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000889 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000890 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
891 {return __table_.__equal_range_multi(__k);}
892
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000893 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000894 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000895 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000896 size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000897
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000898 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000899 size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000900 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000901 size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
902
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000903 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000904 local_iterator begin(size_type __n) {return __table_.begin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000905 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000906 local_iterator end(size_type __n) {return __table_.end(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000907 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000908 const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000909 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000910 const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000911 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000912 const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000913 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000914 const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
915
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000916 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000917 float load_factor() const _NOEXCEPT {return __table_.load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000918 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000919 float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000920 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000921 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000922 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000923 void rehash(size_type __n) {__table_.rehash(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000924 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000925 void reserve(size_type __n) {__table_.reserve(__n);}
926};
927
928template <class _Value, class _Hash, class _Pred, class _Alloc>
929unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
930 size_type __n, const hasher& __hf, const key_equal& __eql)
931 : __table_(__hf, __eql)
932{
933 __table_.rehash(__n);
934}
935
936template <class _Value, class _Hash, class _Pred, class _Alloc>
937unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
938 size_type __n, const hasher& __hf, const key_equal& __eql,
939 const allocator_type& __a)
940 : __table_(__hf, __eql, __a)
941{
942 __table_.rehash(__n);
943}
944
945template <class _Value, class _Hash, class _Pred, class _Alloc>
946template <class _InputIterator>
947unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
948 _InputIterator __first, _InputIterator __last)
949{
950 insert(__first, __last);
951}
952
953template <class _Value, class _Hash, class _Pred, class _Alloc>
954template <class _InputIterator>
955unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
956 _InputIterator __first, _InputIterator __last, size_type __n,
957 const hasher& __hf, const key_equal& __eql)
958 : __table_(__hf, __eql)
959{
960 __table_.rehash(__n);
961 insert(__first, __last);
962}
963
964template <class _Value, class _Hash, class _Pred, class _Alloc>
965template <class _InputIterator>
966unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
967 _InputIterator __first, _InputIterator __last, size_type __n,
968 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
969 : __table_(__hf, __eql, __a)
970{
971 __table_.rehash(__n);
972 insert(__first, __last);
973}
974
975template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000976inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000977unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
978 const allocator_type& __a)
979 : __table_(__a)
980{
981}
982
983template <class _Value, class _Hash, class _Pred, class _Alloc>
984unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
985 const unordered_multiset& __u)
986 : __table_(__u.__table_)
987{
988 __table_.rehash(__u.bucket_count());
989 insert(__u.begin(), __u.end());
990}
991
992template <class _Value, class _Hash, class _Pred, class _Alloc>
993unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
994 const unordered_multiset& __u, const allocator_type& __a)
995 : __table_(__u.__table_, __a)
996{
997 __table_.rehash(__u.bucket_count());
998 insert(__u.begin(), __u.end());
999}
1000
Howard Hinnant73d21a42010-09-04 23:28:19 +00001001#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001002
1003template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001004inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001005unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1006 unordered_multiset&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:37 +00001007 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
Howard Hinnant0949eed2011-06-30 21:18:19 +00001008 : __table_(_VSTD::move(__u.__table_))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001009{
1010}
1011
1012template <class _Value, class _Hash, class _Pred, class _Alloc>
1013unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1014 unordered_multiset&& __u, const allocator_type& __a)
Howard Hinnant0949eed2011-06-30 21:18:19 +00001015 : __table_(_VSTD::move(__u.__table_), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001016{
1017 if (__a != __u.get_allocator())
1018 {
1019 iterator __i = __u.begin();
1020 while (__u.size() != 0)
Howard Hinnant0949eed2011-06-30 21:18:19 +00001021 __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001022 }
1023}
1024
Howard Hinnant73d21a42010-09-04 23:28:19 +00001025#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001026
Howard Hinnante3e32912011-08-12 21:56:02 +00001027#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1028
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001029template <class _Value, class _Hash, class _Pred, class _Alloc>
1030unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1031 initializer_list<value_type> __il)
1032{
1033 insert(__il.begin(), __il.end());
1034}
1035
1036template <class _Value, class _Hash, class _Pred, class _Alloc>
1037unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1038 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1039 const key_equal& __eql)
1040 : __table_(__hf, __eql)
1041{
1042 __table_.rehash(__n);
1043 insert(__il.begin(), __il.end());
1044}
1045
1046template <class _Value, class _Hash, class _Pred, class _Alloc>
1047unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1048 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1049 const key_equal& __eql, const allocator_type& __a)
1050 : __table_(__hf, __eql, __a)
1051{
1052 __table_.rehash(__n);
1053 insert(__il.begin(), __il.end());
1054}
1055
Howard Hinnante3e32912011-08-12 21:56:02 +00001056#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1057
Howard Hinnant73d21a42010-09-04 23:28:19 +00001058#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001059
1060template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001061inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001062unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1063unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
1064 unordered_multiset&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:37 +00001065 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001066{
Howard Hinnant0949eed2011-06-30 21:18:19 +00001067 __table_ = _VSTD::move(__u.__table_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001068 return *this;
1069}
1070
Howard Hinnant73d21a42010-09-04 23:28:19 +00001071#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001072
Howard Hinnante3e32912011-08-12 21:56:02 +00001073#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1074
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001075template <class _Value, class _Hash, class _Pred, class _Alloc>
1076inline
1077unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1078unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
1079 initializer_list<value_type> __il)
1080{
1081 __table_.__assign_multi(__il.begin(), __il.end());
1082 return *this;
1083}
1084
Howard Hinnante3e32912011-08-12 21:56:02 +00001085#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1086
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001087template <class _Value, class _Hash, class _Pred, class _Alloc>
1088template <class _InputIterator>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001089inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001090void
1091unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
1092 _InputIterator __last)
1093{
1094 for (; __first != __last; ++__first)
1095 __table_.__insert_multi(*__first);
1096}
1097
1098template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001099inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001100void
1101swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1102 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
Howard Hinnant04dae1d2011-06-04 20:18:37 +00001103 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001104{
1105 __x.swap(__y);
1106}
1107
1108template <class _Value, class _Hash, class _Pred, class _Alloc>
1109bool
1110operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1111 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1112{
1113 if (__x.size() != __y.size())
1114 return false;
1115 typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
1116 const_iterator;
1117 typedef pair<const_iterator, const_iterator> _EqRng;
1118 for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
1119 {
1120 _EqRng __xeq = __x.equal_range(*__i);
1121 _EqRng __yeq = __y.equal_range(*__i);
Howard Hinnant0949eed2011-06-30 21:18:19 +00001122 if (_VSTD::distance(__xeq.first, __xeq.second) !=
1123 _VSTD::distance(__yeq.first, __yeq.second) ||
1124 !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001125 return false;
1126 __i = __xeq.second;
1127 }
1128 return true;
1129}
1130
1131template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001132inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001133bool
1134operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1135 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1136{
1137 return !(__x == __y);
1138}
1139
1140_LIBCPP_END_NAMESPACE_STD
1141
1142#endif // _LIBCPP_UNORDERED_SET