blob: 279e90723d65a1961ec63156fd27168f6561fc99 [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
Howard Hinnant08e17472011-10-17 20:05:10 +0000308#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000309#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000310#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000311
312_LIBCPP_BEGIN_NAMESPACE_STD
313
314template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
315 class _Alloc = allocator<_Value> >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000316class _LIBCPP_VISIBLE unordered_set
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000317{
318public:
319 // types
320 typedef _Value key_type;
321 typedef key_type value_type;
322 typedef _Hash hasher;
323 typedef _Pred key_equal;
324 typedef _Alloc allocator_type;
325 typedef value_type& reference;
326 typedef const value_type& const_reference;
327
328private:
329 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
330
331 __table __table_;
332
333public:
334 typedef typename __table::pointer pointer;
335 typedef typename __table::const_pointer const_pointer;
336 typedef typename __table::size_type size_type;
337 typedef typename __table::difference_type difference_type;
338
339 typedef typename __table::const_iterator iterator;
340 typedef typename __table::const_iterator const_iterator;
341 typedef typename __table::const_local_iterator local_iterator;
342 typedef typename __table::const_local_iterator const_local_iterator;
343
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000344 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000345 unordered_set()
346 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
347 {} // = default;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000348 explicit unordered_set(size_type __n, const hasher& __hf = hasher(),
349 const key_equal& __eql = key_equal());
350 unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql,
351 const allocator_type& __a);
352 template <class _InputIterator>
353 unordered_set(_InputIterator __first, _InputIterator __last);
354 template <class _InputIterator>
355 unordered_set(_InputIterator __first, _InputIterator __last,
356 size_type __n, const hasher& __hf = hasher(),
357 const key_equal& __eql = key_equal());
358 template <class _InputIterator>
359 unordered_set(_InputIterator __first, _InputIterator __last,
360 size_type __n, const hasher& __hf, const key_equal& __eql,
361 const allocator_type& __a);
362 explicit unordered_set(const allocator_type& __a);
363 unordered_set(const unordered_set& __u);
364 unordered_set(const unordered_set& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19 +0000365#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000366 unordered_set(unordered_set&& __u)
367 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000368 unordered_set(unordered_set&& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19 +0000369#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnante3e32912011-08-12 21:56:02 +0000370#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000371 unordered_set(initializer_list<value_type> __il);
372 unordered_set(initializer_list<value_type> __il, size_type __n,
373 const hasher& __hf = hasher(),
374 const key_equal& __eql = key_equal());
375 unordered_set(initializer_list<value_type> __il, size_type __n,
376 const hasher& __hf, const key_equal& __eql,
377 const allocator_type& __a);
Howard Hinnante3e32912011-08-12 21:56:02 +0000378#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000379 // ~unordered_set() = default;
Howard Hinnant61aa6012011-07-01 19:24:36 +0000380 _LIBCPP_INLINE_VISIBILITY
381 unordered_set& operator=(const unordered_set& __u)
382 {
383 __table_ = __u.__table_;
384 return *this;
385 }
Howard Hinnant73d21a42010-09-04 23:28:19 +0000386#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000387 unordered_set& operator=(unordered_set&& __u)
388 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000389#endif
Howard Hinnante3e32912011-08-12 21:56:02 +0000390#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000391 unordered_set& operator=(initializer_list<value_type> __il);
Howard Hinnante3e32912011-08-12 21:56:02 +0000392#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000393
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000394 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000395 allocator_type get_allocator() const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000396 {return allocator_type(__table_.__node_alloc());}
397
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000398 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000399 bool empty() const _NOEXCEPT {return __table_.size() == 0;}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000400 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000401 size_type size() const _NOEXCEPT {return __table_.size();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000402 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000403 size_type max_size() const _NOEXCEPT {return __table_.max_size();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000404
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000405 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000406 iterator begin() _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000407 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000408 iterator end() _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000409 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000410 const_iterator begin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000411 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000412 const_iterator end() const _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000413 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000414 const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000415 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000416 const_iterator cend() const _NOEXCEPT {return __table_.end();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000417
Howard Hinnant73d21a42010-09-04 23:28:19 +0000418#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000419 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000420 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000421 pair<iterator, bool> emplace(_Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000422 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000423 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000424 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000425 iterator emplace_hint(const_iterator, _Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000426 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000427#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000428 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000429 pair<iterator, bool> insert(const value_type& __x)
430 {return __table_.__insert_unique(__x);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000431#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000432 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000433 pair<iterator, bool> insert(value_type&& __x)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000434 {return __table_.__insert_unique(_VSTD::move(__x));}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000435#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000436 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000437 iterator insert(const_iterator, const value_type& __x)
438 {return insert(__x).first;}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000439#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000440 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000441 iterator insert(const_iterator, value_type&& __x)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000442 {return insert(_VSTD::move(__x)).first;}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000443#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000444 template <class _InputIterator>
445 void insert(_InputIterator __first, _InputIterator __last);
Howard Hinnante3e32912011-08-12 21:56:02 +0000446#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000447 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000448 void insert(initializer_list<value_type> __il)
449 {insert(__il.begin(), __il.end());}
Howard Hinnante3e32912011-08-12 21:56:02 +0000450#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000451
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000452 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000453 iterator erase(const_iterator __p) {return __table_.erase(__p);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000454 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000455 size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000456 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000457 iterator erase(const_iterator __first, const_iterator __last)
458 {return __table_.erase(__first, __last);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000459 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000460 void clear() _NOEXCEPT {__table_.clear();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000461
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000462 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000463 void swap(unordered_set& __u)
464 _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
465 {__table_.swap(__u.__table_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000466
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000467 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000468 hasher hash_function() const {return __table_.hash_function();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000469 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000470 key_equal key_eq() const {return __table_.key_eq();}
471
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000472 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000473 iterator find(const key_type& __k) {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000474 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000475 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000476 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000477 size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000478 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000479 pair<iterator, iterator> equal_range(const key_type& __k)
480 {return __table_.__equal_range_unique(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000481 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000482 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
483 {return __table_.__equal_range_unique(__k);}
484
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000485 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000486 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000487 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000488 size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000489
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000490 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000491 size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000492 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000493 size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
494
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000495 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000496 local_iterator begin(size_type __n) {return __table_.begin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000497 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000498 local_iterator end(size_type __n) {return __table_.end(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000499 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000500 const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000501 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000502 const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000503 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000504 const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000505 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000506 const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
507
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000508 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000509 float load_factor() const _NOEXCEPT {return __table_.load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000510 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000511 float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000512 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000513 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000514 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000515 void rehash(size_type __n) {__table_.rehash(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000516 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000517 void reserve(size_type __n) {__table_.reserve(__n);}
518};
519
520template <class _Value, class _Hash, class _Pred, class _Alloc>
521unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
522 const hasher& __hf, const key_equal& __eql)
523 : __table_(__hf, __eql)
524{
525 __table_.rehash(__n);
526}
527
528template <class _Value, class _Hash, class _Pred, class _Alloc>
529unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
530 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
531 : __table_(__hf, __eql, __a)
532{
533 __table_.rehash(__n);
534}
535
536template <class _Value, class _Hash, class _Pred, class _Alloc>
537template <class _InputIterator>
538unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
539 _InputIterator __first, _InputIterator __last)
540{
541 insert(__first, __last);
542}
543
544template <class _Value, class _Hash, class _Pred, class _Alloc>
545template <class _InputIterator>
546unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
547 _InputIterator __first, _InputIterator __last, size_type __n,
548 const hasher& __hf, const key_equal& __eql)
549 : __table_(__hf, __eql)
550{
551 __table_.rehash(__n);
552 insert(__first, __last);
553}
554
555template <class _Value, class _Hash, class _Pred, class _Alloc>
556template <class _InputIterator>
557unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
558 _InputIterator __first, _InputIterator __last, size_type __n,
559 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
560 : __table_(__hf, __eql, __a)
561{
562 __table_.rehash(__n);
563 insert(__first, __last);
564}
565
566template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000567inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000568unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
569 const allocator_type& __a)
570 : __table_(__a)
571{
572}
573
574template <class _Value, class _Hash, class _Pred, class _Alloc>
575unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
576 const unordered_set& __u)
577 : __table_(__u.__table_)
578{
579 __table_.rehash(__u.bucket_count());
580 insert(__u.begin(), __u.end());
581}
582
583template <class _Value, class _Hash, class _Pred, class _Alloc>
584unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
585 const unordered_set& __u, const allocator_type& __a)
586 : __table_(__u.__table_, __a)
587{
588 __table_.rehash(__u.bucket_count());
589 insert(__u.begin(), __u.end());
590}
591
Howard Hinnant73d21a42010-09-04 23:28:19 +0000592#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000593
594template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000595inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000596unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
597 unordered_set&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000598 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000599 : __table_(_VSTD::move(__u.__table_))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000600{
601}
602
603template <class _Value, class _Hash, class _Pred, class _Alloc>
604unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
605 unordered_set&& __u, const allocator_type& __a)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000606 : __table_(_VSTD::move(__u.__table_), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000607{
608 if (__a != __u.get_allocator())
609 {
610 iterator __i = __u.begin();
611 while (__u.size() != 0)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000612 __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000613 }
614}
615
Howard Hinnant73d21a42010-09-04 23:28:19 +0000616#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000617
Howard Hinnante3e32912011-08-12 21:56:02 +0000618#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
619
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000620template <class _Value, class _Hash, class _Pred, class _Alloc>
621unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
622 initializer_list<value_type> __il)
623{
624 insert(__il.begin(), __il.end());
625}
626
627template <class _Value, class _Hash, class _Pred, class _Alloc>
628unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
629 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
630 const key_equal& __eql)
631 : __table_(__hf, __eql)
632{
633 __table_.rehash(__n);
634 insert(__il.begin(), __il.end());
635}
636
637template <class _Value, class _Hash, class _Pred, class _Alloc>
638unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
639 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
640 const key_equal& __eql, const allocator_type& __a)
641 : __table_(__hf, __eql, __a)
642{
643 __table_.rehash(__n);
644 insert(__il.begin(), __il.end());
645}
646
Howard Hinnante3e32912011-08-12 21:56:02 +0000647#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
648
Howard Hinnant73d21a42010-09-04 23:28:19 +0000649#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000650
651template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000652inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000653unordered_set<_Value, _Hash, _Pred, _Alloc>&
654unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000655 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000656{
Howard Hinnant0949eed2011-06-30 21:18:19 +0000657 __table_ = _VSTD::move(__u.__table_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000658 return *this;
659}
660
Howard Hinnant73d21a42010-09-04 23:28:19 +0000661#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000662
Howard Hinnante3e32912011-08-12 21:56:02 +0000663#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
664
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000665template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000666inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000667unordered_set<_Value, _Hash, _Pred, _Alloc>&
668unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
669 initializer_list<value_type> __il)
670{
671 __table_.__assign_unique(__il.begin(), __il.end());
672 return *this;
673}
674
Howard Hinnante3e32912011-08-12 21:56:02 +0000675#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
676
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000677template <class _Value, class _Hash, class _Pred, class _Alloc>
678template <class _InputIterator>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000679inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000680void
681unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
682 _InputIterator __last)
683{
684 for (; __first != __last; ++__first)
685 __table_.__insert_unique(*__first);
686}
687
688template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000689inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000690void
691swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
692 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000693 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000694{
695 __x.swap(__y);
696}
697
698template <class _Value, class _Hash, class _Pred, class _Alloc>
699bool
700operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
701 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
702{
703 if (__x.size() != __y.size())
704 return false;
705 typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
706 const_iterator;
707 for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
708 __i != __ex; ++__i)
709 {
710 const_iterator __j = __y.find(*__i);
711 if (__j == __ey || !(*__i == *__j))
712 return false;
713 }
714 return true;
715}
716
717template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000718inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000719bool
720operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
721 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
722{
723 return !(__x == __y);
724}
725
726template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
727 class _Alloc = allocator<_Value> >
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000728class _LIBCPP_VISIBLE unordered_multiset
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000729{
730public:
731 // types
732 typedef _Value key_type;
733 typedef key_type value_type;
734 typedef _Hash hasher;
735 typedef _Pred key_equal;
736 typedef _Alloc allocator_type;
737 typedef value_type& reference;
738 typedef const value_type& const_reference;
739
740private:
741 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
742
743 __table __table_;
744
745public:
746 typedef typename __table::pointer pointer;
747 typedef typename __table::const_pointer const_pointer;
748 typedef typename __table::size_type size_type;
749 typedef typename __table::difference_type difference_type;
750
751 typedef typename __table::const_iterator iterator;
752 typedef typename __table::const_iterator const_iterator;
753 typedef typename __table::const_local_iterator local_iterator;
754 typedef typename __table::const_local_iterator const_local_iterator;
755
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000756 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000757 unordered_multiset()
758 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
759 {} // = default
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000760 explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(),
761 const key_equal& __eql = key_equal());
762 unordered_multiset(size_type __n, const hasher& __hf,
763 const key_equal& __eql, const allocator_type& __a);
764 template <class _InputIterator>
765 unordered_multiset(_InputIterator __first, _InputIterator __last);
766 template <class _InputIterator>
767 unordered_multiset(_InputIterator __first, _InputIterator __last,
768 size_type __n, const hasher& __hf = hasher(),
769 const key_equal& __eql = key_equal());
770 template <class _InputIterator>
771 unordered_multiset(_InputIterator __first, _InputIterator __last,
772 size_type __n , const hasher& __hf,
773 const key_equal& __eql, const allocator_type& __a);
774 explicit unordered_multiset(const allocator_type& __a);
775 unordered_multiset(const unordered_multiset& __u);
776 unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19 +0000777#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000778 unordered_multiset(unordered_multiset&& __u)
779 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000780 unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19 +0000781#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnante3e32912011-08-12 21:56:02 +0000782#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000783 unordered_multiset(initializer_list<value_type> __il);
784 unordered_multiset(initializer_list<value_type> __il, size_type __n,
785 const hasher& __hf = hasher(),
786 const key_equal& __eql = key_equal());
787 unordered_multiset(initializer_list<value_type> __il, size_type __n,
788 const hasher& __hf, const key_equal& __eql,
789 const allocator_type& __a);
Howard Hinnante3e32912011-08-12 21:56:02 +0000790#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000791 // ~unordered_multiset() = default;
Howard Hinnant61aa6012011-07-01 19:24:36 +0000792 _LIBCPP_INLINE_VISIBILITY
793 unordered_multiset& operator=(const unordered_multiset& __u)
794 {
795 __table_ = __u.__table_;
796 return *this;
797 }
Howard Hinnant73d21a42010-09-04 23:28:19 +0000798#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000799 unordered_multiset& operator=(unordered_multiset&& __u)
800 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000801#endif
Howard Hinnante3e32912011-08-12 21:56:02 +0000802#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000803 unordered_multiset& operator=(initializer_list<value_type> __il);
Howard Hinnante3e32912011-08-12 21:56:02 +0000804#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000805
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000806 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000807 allocator_type get_allocator() const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000808 {return allocator_type(__table_.__node_alloc());}
809
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000810 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000811 bool empty() const _NOEXCEPT {return __table_.size() == 0;}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000812 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000813 size_type size() const _NOEXCEPT {return __table_.size();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000814 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000815 size_type max_size() const _NOEXCEPT {return __table_.max_size();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000816
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000817 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000818 iterator begin() _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000819 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000820 iterator end() _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000821 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000822 const_iterator begin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000823 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000824 const_iterator end() const _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000825 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000826 const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000827 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000828 const_iterator cend() const _NOEXCEPT {return __table_.end();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000829
Howard Hinnant73d21a42010-09-04 23:28:19 +0000830#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000831 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000832 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000833 iterator emplace(_Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000834 {return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000835 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000836 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000837 iterator emplace_hint(const_iterator __p, _Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000838 {return __table_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000839#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000840 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000841 iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000842#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000843 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant0949eed2011-06-30 21:18:19 +0000844 iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000845#endif
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000846 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000847 iterator insert(const_iterator __p, const value_type& __x)
848 {return __table_.__insert_multi(__p, __x);}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000849#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000850 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000851 iterator insert(const_iterator __p, value_type&& __x)
Howard Hinnant0949eed2011-06-30 21:18:19 +0000852 {return __table_.__insert_multi(__p, _VSTD::move(__x));}
Howard Hinnant73d21a42010-09-04 23:28:19 +0000853#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000854 template <class _InputIterator>
855 void insert(_InputIterator __first, _InputIterator __last);
Howard Hinnante3e32912011-08-12 21:56:02 +0000856#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000857 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000858 void insert(initializer_list<value_type> __il)
859 {insert(__il.begin(), __il.end());}
Howard Hinnante3e32912011-08-12 21:56:02 +0000860#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000861
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000862 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000863 iterator erase(const_iterator __p) {return __table_.erase(__p);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000864 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000865 size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000866 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000867 iterator erase(const_iterator __first, const_iterator __last)
868 {return __table_.erase(__first, __last);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000869 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000870 void clear() _NOEXCEPT {__table_.clear();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000871
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000872 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000873 void swap(unordered_multiset& __u)
874 _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
875 {__table_.swap(__u.__table_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000876
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000877 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000878 hasher hash_function() const {return __table_.hash_function();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000879 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000880 key_equal key_eq() const {return __table_.key_eq();}
881
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000882 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000883 iterator find(const key_type& __k) {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000884 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000885 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000886 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000887 size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000888 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000889 pair<iterator, iterator> equal_range(const key_type& __k)
890 {return __table_.__equal_range_multi(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000891 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000892 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
893 {return __table_.__equal_range_multi(__k);}
894
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000895 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000896 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000897 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000898 size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000899
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000900 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000901 size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000902 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000903 size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
904
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000905 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000906 local_iterator begin(size_type __n) {return __table_.begin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000907 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000908 local_iterator end(size_type __n) {return __table_.end(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000909 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000910 const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000911 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000912 const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000913 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000914 const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000915 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000916 const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
917
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000918 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000919 float load_factor() const _NOEXCEPT {return __table_.load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000920 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37 +0000921 float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000922 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000923 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000924 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000925 void rehash(size_type __n) {__table_.rehash(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000926 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000927 void reserve(size_type __n) {__table_.reserve(__n);}
928};
929
930template <class _Value, class _Hash, class _Pred, class _Alloc>
931unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
932 size_type __n, const hasher& __hf, const key_equal& __eql)
933 : __table_(__hf, __eql)
934{
935 __table_.rehash(__n);
936}
937
938template <class _Value, class _Hash, class _Pred, class _Alloc>
939unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
940 size_type __n, const hasher& __hf, const key_equal& __eql,
941 const allocator_type& __a)
942 : __table_(__hf, __eql, __a)
943{
944 __table_.rehash(__n);
945}
946
947template <class _Value, class _Hash, class _Pred, class _Alloc>
948template <class _InputIterator>
949unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
950 _InputIterator __first, _InputIterator __last)
951{
952 insert(__first, __last);
953}
954
955template <class _Value, class _Hash, class _Pred, class _Alloc>
956template <class _InputIterator>
957unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
958 _InputIterator __first, _InputIterator __last, size_type __n,
959 const hasher& __hf, const key_equal& __eql)
960 : __table_(__hf, __eql)
961{
962 __table_.rehash(__n);
963 insert(__first, __last);
964}
965
966template <class _Value, class _Hash, class _Pred, class _Alloc>
967template <class _InputIterator>
968unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
969 _InputIterator __first, _InputIterator __last, size_type __n,
970 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
971 : __table_(__hf, __eql, __a)
972{
973 __table_.rehash(__n);
974 insert(__first, __last);
975}
976
977template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000978inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000979unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
980 const allocator_type& __a)
981 : __table_(__a)
982{
983}
984
985template <class _Value, class _Hash, class _Pred, class _Alloc>
986unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
987 const unordered_multiset& __u)
988 : __table_(__u.__table_)
989{
990 __table_.rehash(__u.bucket_count());
991 insert(__u.begin(), __u.end());
992}
993
994template <class _Value, class _Hash, class _Pred, class _Alloc>
995unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
996 const unordered_multiset& __u, const allocator_type& __a)
997 : __table_(__u.__table_, __a)
998{
999 __table_.rehash(__u.bucket_count());
1000 insert(__u.begin(), __u.end());
1001}
1002
Howard Hinnant73d21a42010-09-04 23:28:19 +00001003#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001004
1005template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001006inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001007unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1008 unordered_multiset&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:37 +00001009 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
Howard Hinnant0949eed2011-06-30 21:18:19 +00001010 : __table_(_VSTD::move(__u.__table_))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001011{
1012}
1013
1014template <class _Value, class _Hash, class _Pred, class _Alloc>
1015unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1016 unordered_multiset&& __u, const allocator_type& __a)
Howard Hinnant0949eed2011-06-30 21:18:19 +00001017 : __table_(_VSTD::move(__u.__table_), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001018{
1019 if (__a != __u.get_allocator())
1020 {
1021 iterator __i = __u.begin();
1022 while (__u.size() != 0)
Howard Hinnant0949eed2011-06-30 21:18:19 +00001023 __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001024 }
1025}
1026
Howard Hinnant73d21a42010-09-04 23:28:19 +00001027#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001028
Howard Hinnante3e32912011-08-12 21:56:02 +00001029#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1030
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001031template <class _Value, class _Hash, class _Pred, class _Alloc>
1032unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1033 initializer_list<value_type> __il)
1034{
1035 insert(__il.begin(), __il.end());
1036}
1037
1038template <class _Value, class _Hash, class _Pred, class _Alloc>
1039unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1040 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1041 const key_equal& __eql)
1042 : __table_(__hf, __eql)
1043{
1044 __table_.rehash(__n);
1045 insert(__il.begin(), __il.end());
1046}
1047
1048template <class _Value, class _Hash, class _Pred, class _Alloc>
1049unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1050 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1051 const key_equal& __eql, const allocator_type& __a)
1052 : __table_(__hf, __eql, __a)
1053{
1054 __table_.rehash(__n);
1055 insert(__il.begin(), __il.end());
1056}
1057
Howard Hinnante3e32912011-08-12 21:56:02 +00001058#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1059
Howard Hinnant73d21a42010-09-04 23:28:19 +00001060#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001061
1062template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001063inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001064unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1065unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
1066 unordered_multiset&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:37 +00001067 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001068{
Howard Hinnant0949eed2011-06-30 21:18:19 +00001069 __table_ = _VSTD::move(__u.__table_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001070 return *this;
1071}
1072
Howard Hinnant73d21a42010-09-04 23:28:19 +00001073#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001074
Howard Hinnante3e32912011-08-12 21:56:02 +00001075#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1076
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001077template <class _Value, class _Hash, class _Pred, class _Alloc>
1078inline
1079unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1080unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
1081 initializer_list<value_type> __il)
1082{
1083 __table_.__assign_multi(__il.begin(), __il.end());
1084 return *this;
1085}
1086
Howard Hinnante3e32912011-08-12 21:56:02 +00001087#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1088
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001089template <class _Value, class _Hash, class _Pred, class _Alloc>
1090template <class _InputIterator>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001091inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001092void
1093unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
1094 _InputIterator __last)
1095{
1096 for (; __first != __last; ++__first)
1097 __table_.__insert_multi(*__first);
1098}
1099
1100template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001101inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001102void
1103swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1104 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
Howard Hinnant04dae1d2011-06-04 20:18:37 +00001105 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001106{
1107 __x.swap(__y);
1108}
1109
1110template <class _Value, class _Hash, class _Pred, class _Alloc>
1111bool
1112operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1113 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1114{
1115 if (__x.size() != __y.size())
1116 return false;
1117 typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
1118 const_iterator;
1119 typedef pair<const_iterator, const_iterator> _EqRng;
1120 for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
1121 {
1122 _EqRng __xeq = __x.equal_range(*__i);
1123 _EqRng __yeq = __y.equal_range(*__i);
Howard Hinnant0949eed2011-06-30 21:18:19 +00001124 if (_VSTD::distance(__xeq.first, __xeq.second) !=
1125 _VSTD::distance(__yeq.first, __yeq.second) ||
1126 !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001127 return false;
1128 __i = __xeq.second;
1129 }
1130 return true;
1131}
1132
1133template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001134inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001135bool
1136operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1137 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1138{
1139 return !(__x == __y);
1140}
1141
1142_LIBCPP_END_NAMESPACE_STD
1143
1144#endif // _LIBCPP_UNORDERED_SET