blob: fc53c82711091f0a879956ec5f8b914a9f301a71 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:161// -*- C++ -*-
2//===-------------------------- unordered_set -----------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:014// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:165//
Howard Hinnantb64f8b02010-11-16 22:09:026// 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:168//
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:3746 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:1652 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:3762 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:1667 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());
Marshall Clowbd444af2013-09-30 21:33:5171 unordered_set(size_type n, const allocator_type& a); // C++14
72 unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14
73 template <class InputIterator>
74 unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
75 template <class InputIterator>
76 unordered_set(InputIterator f, InputIterator l, size_type n,
77 const hasher& hf, const allocator_type& a); // C++14
78 unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
79 unordered_set(initializer_list<value_type> il, size_type n,
80 const hasher& hf, const allocator_type& a); // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:1681 ~unordered_set();
82 unordered_set& operator=(const unordered_set&);
Howard Hinnant04dae1d2011-06-04 20:18:3783 unordered_set& operator=(unordered_set&&)
84 noexcept(
85 allocator_type::propagate_on_container_move_assignment::value &&
86 is_nothrow_move_assignable<allocator_type>::value &&
87 is_nothrow_move_assignable<hasher>::value &&
88 is_nothrow_move_assignable<key_equal>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:1689 unordered_set& operator=(initializer_list<value_type>);
90
Howard Hinnant04dae1d2011-06-04 20:18:3791 allocator_type get_allocator() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1692
Howard Hinnant04dae1d2011-06-04 20:18:3793 bool empty() const noexcept;
94 size_type size() const noexcept;
95 size_type max_size() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:1696
Howard Hinnant04dae1d2011-06-04 20:18:3797 iterator begin() noexcept;
98 iterator end() noexcept;
99 const_iterator begin() const noexcept;
100 const_iterator end() const noexcept;
101 const_iterator cbegin() const noexcept;
102 const_iterator cend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16103
104 template <class... Args>
105 pair<iterator, bool> emplace(Args&&... args);
106 template <class... Args>
107 iterator emplace_hint(const_iterator position, Args&&... args);
108 pair<iterator, bool> insert(const value_type& obj);
109 pair<iterator, bool> insert(value_type&& obj);
110 iterator insert(const_iterator hint, const value_type& obj);
111 iterator insert(const_iterator hint, value_type&& obj);
112 template <class InputIterator>
113 void insert(InputIterator first, InputIterator last);
114 void insert(initializer_list<value_type>);
115
116 iterator erase(const_iterator position);
Marshall Clow488025c2015-05-10 13:35:00117 iterator erase(iterator position); // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16118 size_type erase(const key_type& k);
119 iterator erase(const_iterator first, const_iterator last);
Howard Hinnant04dae1d2011-06-04 20:18:37120 void clear() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16121
Howard Hinnant04dae1d2011-06-04 20:18:37122 void swap(unordered_set&)
Marshall Clow7d914d12015-07-13 20:04:56123 noexcept(allocator_traits<Allocator>::is_always_equal::value &&
124 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
125 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
Howard Hinnantbc8d3f92010-05-11 19:42:16126
127 hasher hash_function() const;
128 key_equal key_eq() const;
129
130 iterator find(const key_type& k);
131 const_iterator find(const key_type& k) const;
132 size_type count(const key_type& k) const;
133 pair<iterator, iterator> equal_range(const key_type& k);
134 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
135
Howard Hinnant04dae1d2011-06-04 20:18:37136 size_type bucket_count() const noexcept;
137 size_type max_bucket_count() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16138
139 size_type bucket_size(size_type n) const;
140 size_type bucket(const key_type& k) const;
141
142 local_iterator begin(size_type n);
143 local_iterator end(size_type n);
144 const_local_iterator begin(size_type n) const;
145 const_local_iterator end(size_type n) const;
146 const_local_iterator cbegin(size_type n) const;
147 const_local_iterator cend(size_type n) const;
148
Howard Hinnant04dae1d2011-06-04 20:18:37149 float load_factor() const noexcept;
150 float max_load_factor() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16151 void max_load_factor(float z);
152 void rehash(size_type n);
153 void reserve(size_type n);
154};
155
156template <class Value, class Hash, class Pred, class Alloc>
157 void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
Howard Hinnant04dae1d2011-06-04 20:18:37158 unordered_set<Value, Hash, Pred, Alloc>& y)
159 noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16160
161template <class Value, class Hash, class Pred, class Alloc>
162 bool
163 operator==(const unordered_set<Value, Hash, Pred, Alloc>& x,
164 const unordered_set<Value, Hash, Pred, Alloc>& y);
165
166template <class Value, class Hash, class Pred, class Alloc>
167 bool
168 operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x,
169 const unordered_set<Value, Hash, Pred, Alloc>& y);
170
171template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
172 class Alloc = allocator<Value>>
173class unordered_multiset
174{
175public:
176 // types
177 typedef Value key_type;
178 typedef key_type value_type;
179 typedef Hash hasher;
180 typedef Pred key_equal;
181 typedef Alloc allocator_type;
182 typedef value_type& reference;
183 typedef const value_type& const_reference;
184 typedef typename allocator_traits<allocator_type>::pointer pointer;
185 typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
186 typedef typename allocator_traits<allocator_type>::size_type size_type;
187 typedef typename allocator_traits<allocator_type>::difference_type difference_type;
188
189 typedef /unspecified/ iterator;
190 typedef /unspecified/ const_iterator;
191 typedef /unspecified/ local_iterator;
192 typedef /unspecified/ const_local_iterator;
193
Howard Hinnant04dae1d2011-06-04 20:18:37194 unordered_multiset()
195 noexcept(
196 is_nothrow_default_constructible<hasher>::value &&
197 is_nothrow_default_constructible<key_equal>::value &&
198 is_nothrow_default_constructible<allocator_type>::value);
199 explicit unordered_multiset(size_type n, const hasher& hf = hasher(),
Howard Hinnantbc8d3f92010-05-11 19:42:16200 const key_equal& eql = key_equal(),
201 const allocator_type& a = allocator_type());
202 template <class InputIterator>
203 unordered_multiset(InputIterator f, InputIterator l,
204 size_type n = 0, const hasher& hf = hasher(),
205 const key_equal& eql = key_equal(),
206 const allocator_type& a = allocator_type());
207 explicit unordered_multiset(const allocator_type&);
208 unordered_multiset(const unordered_multiset&);
209 unordered_multiset(const unordered_multiset&, const Allocator&);
Howard Hinnant04dae1d2011-06-04 20:18:37210 unordered_multiset(unordered_multiset&&)
211 noexcept(
212 is_nothrow_move_constructible<hasher>::value &&
213 is_nothrow_move_constructible<key_equal>::value &&
214 is_nothrow_move_constructible<allocator_type>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16215 unordered_multiset(unordered_multiset&&, const Allocator&);
216 unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
217 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
218 const allocator_type& a = allocator_type());
Marshall Clowbd444af2013-09-30 21:33:51219 unordered_multiset(size_type n, const allocator_type& a); // C++14
220 unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14
221 template <class InputIterator>
222 unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
223 template <class InputIterator>
224 unordered_multiset(InputIterator f, InputIterator l, size_type n,
225 const hasher& hf, const allocator_type& a); // C++14
226 unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
227 unordered_multiset(initializer_list<value_type> il, size_type n,
228 const hasher& hf, const allocator_type& a); // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16229 ~unordered_multiset();
230 unordered_multiset& operator=(const unordered_multiset&);
Howard Hinnant04dae1d2011-06-04 20:18:37231 unordered_multiset& operator=(unordered_multiset&&)
232 noexcept(
233 allocator_type::propagate_on_container_move_assignment::value &&
234 is_nothrow_move_assignable<allocator_type>::value &&
235 is_nothrow_move_assignable<hasher>::value &&
236 is_nothrow_move_assignable<key_equal>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16237 unordered_multiset& operator=(initializer_list<value_type>);
238
Howard Hinnant04dae1d2011-06-04 20:18:37239 allocator_type get_allocator() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16240
Howard Hinnant04dae1d2011-06-04 20:18:37241 bool empty() const noexcept;
242 size_type size() const noexcept;
243 size_type max_size() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16244
Howard Hinnant04dae1d2011-06-04 20:18:37245 iterator begin() noexcept;
246 iterator end() noexcept;
247 const_iterator begin() const noexcept;
248 const_iterator end() const noexcept;
249 const_iterator cbegin() const noexcept;
250 const_iterator cend() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16251
252 template <class... Args>
253 iterator emplace(Args&&... args);
254 template <class... Args>
255 iterator emplace_hint(const_iterator position, Args&&... args);
256 iterator insert(const value_type& obj);
257 iterator insert(value_type&& obj);
258 iterator insert(const_iterator hint, const value_type& obj);
259 iterator insert(const_iterator hint, value_type&& obj);
260 template <class InputIterator>
261 void insert(InputIterator first, InputIterator last);
262 void insert(initializer_list<value_type>);
263
264 iterator erase(const_iterator position);
Marshall Clow488025c2015-05-10 13:35:00265 iterator erase(iterator position); // C++14
Howard Hinnantbc8d3f92010-05-11 19:42:16266 size_type erase(const key_type& k);
267 iterator erase(const_iterator first, const_iterator last);
Howard Hinnant04dae1d2011-06-04 20:18:37268 void clear() noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16269
Howard Hinnant04dae1d2011-06-04 20:18:37270 void swap(unordered_multiset&)
Marshall Clow7d914d12015-07-13 20:04:56271 noexcept(allocator_traits<Allocator>::is_always_equal::value &&
272 noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
273 noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
Howard Hinnantbc8d3f92010-05-11 19:42:16274
275 hasher hash_function() const;
276 key_equal key_eq() const;
277
278 iterator find(const key_type& k);
279 const_iterator find(const key_type& k) const;
280 size_type count(const key_type& k) const;
281 pair<iterator, iterator> equal_range(const key_type& k);
282 pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
283
Howard Hinnant04dae1d2011-06-04 20:18:37284 size_type bucket_count() const noexcept;
285 size_type max_bucket_count() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16286
287 size_type bucket_size(size_type n) const;
288 size_type bucket(const key_type& k) const;
289
290 local_iterator begin(size_type n);
291 local_iterator end(size_type n);
292 const_local_iterator begin(size_type n) const;
293 const_local_iterator end(size_type n) const;
294 const_local_iterator cbegin(size_type n) const;
295 const_local_iterator cend(size_type n) const;
296
Howard Hinnant04dae1d2011-06-04 20:18:37297 float load_factor() const noexcept;
298 float max_load_factor() const noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16299 void max_load_factor(float z);
300 void rehash(size_type n);
301 void reserve(size_type n);
302};
303
304template <class Value, class Hash, class Pred, class Alloc>
305 void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
Howard Hinnant04dae1d2011-06-04 20:18:37306 unordered_multiset<Value, Hash, Pred, Alloc>& y)
307 noexcept(noexcept(x.swap(y)));
Howard Hinnantbc8d3f92010-05-11 19:42:16308
309template <class Value, class Hash, class Pred, class Alloc>
310 bool
311 operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
312 const unordered_multiset<Value, Hash, Pred, Alloc>& y);
313
314template <class Value, class Hash, class Pred, class Alloc>
315 bool
316 operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
317 const unordered_multiset<Value, Hash, Pred, Alloc>& y);
318} // std
319
320*/
321
322#include <__config>
323#include <__hash_table>
324#include <functional>
325
Eric Fiselierb9536102014-08-10 23:53:08326#include <__debug>
327
Howard Hinnant08e17472011-10-17 20:05:10328#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16329#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10330#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16331
332_LIBCPP_BEGIN_NAMESPACE_STD
333
334template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
335 class _Alloc = allocator<_Value> >
Eric Fiselierc3589a82017-01-04 23:56:00336class _LIBCPP_TEMPLATE_VIS unordered_set
Howard Hinnantbc8d3f92010-05-11 19:42:16337{
338public:
339 // types
340 typedef _Value key_type;
341 typedef key_type value_type;
342 typedef _Hash hasher;
343 typedef _Pred key_equal;
344 typedef _Alloc allocator_type;
345 typedef value_type& reference;
346 typedef const value_type& const_reference;
Howard Hinnant39213642013-07-23 22:01:58347 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
348 "Invalid allocator::value_type");
Howard Hinnantbc8d3f92010-05-11 19:42:16349
350private:
351 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
352
353 __table __table_;
354
355public:
356 typedef typename __table::pointer pointer;
357 typedef typename __table::const_pointer const_pointer;
358 typedef typename __table::size_type size_type;
359 typedef typename __table::difference_type difference_type;
360
361 typedef typename __table::const_iterator iterator;
362 typedef typename __table::const_iterator const_iterator;
363 typedef typename __table::const_local_iterator local_iterator;
364 typedef typename __table::const_local_iterator const_local_iterator;
365
Howard Hinnantee6ccd02010-09-23 18:58:28366 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37367 unordered_set()
368 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
Howard Hinnant39213642013-07-23 22:01:58369 {
370#if _LIBCPP_DEBUG_LEVEL >= 2
371 __get_db()->__insert_c(this);
372#endif
373 }
Howard Hinnantbc8d3f92010-05-11 19:42:16374 explicit unordered_set(size_type __n, const hasher& __hf = hasher(),
375 const key_equal& __eql = key_equal());
Marshall Clowbd444af2013-09-30 21:33:51376#if _LIBCPP_STD_VER > 11
377 inline _LIBCPP_INLINE_VISIBILITY
378 unordered_set(size_type __n, const allocator_type& __a)
379 : unordered_set(__n, hasher(), key_equal(), __a) {}
380 inline _LIBCPP_INLINE_VISIBILITY
381 unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
382 : unordered_set(__n, __hf, key_equal(), __a) {}
383#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16384 unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql,
385 const allocator_type& __a);
386 template <class _InputIterator>
387 unordered_set(_InputIterator __first, _InputIterator __last);
388 template <class _InputIterator>
389 unordered_set(_InputIterator __first, _InputIterator __last,
390 size_type __n, const hasher& __hf = hasher(),
391 const key_equal& __eql = key_equal());
392 template <class _InputIterator>
393 unordered_set(_InputIterator __first, _InputIterator __last,
394 size_type __n, const hasher& __hf, const key_equal& __eql,
395 const allocator_type& __a);
Marshall Clowbd444af2013-09-30 21:33:51396#if _LIBCPP_STD_VER > 11
397 template <class _InputIterator>
398 inline _LIBCPP_INLINE_VISIBILITY
399 unordered_set(_InputIterator __first, _InputIterator __last,
400 size_type __n, const allocator_type& __a)
401 : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {}
402 template <class _InputIterator>
403 unordered_set(_InputIterator __first, _InputIterator __last,
404 size_type __n, const hasher& __hf, const allocator_type& __a)
405 : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
406#endif
Evgeniy Stepanov9341a8a2016-04-22 01:04:55407 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16408 explicit unordered_set(const allocator_type& __a);
409 unordered_set(const unordered_set& __u);
410 unordered_set(const unordered_set& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19411#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Evgeniy Stepanov9341a8a2016-04-22 01:04:55412 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37413 unordered_set(unordered_set&& __u)
414 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16415 unordered_set(unordered_set&& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19416#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnante3e32912011-08-12 21:56:02417#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16418 unordered_set(initializer_list<value_type> __il);
419 unordered_set(initializer_list<value_type> __il, size_type __n,
420 const hasher& __hf = hasher(),
421 const key_equal& __eql = key_equal());
422 unordered_set(initializer_list<value_type> __il, size_type __n,
423 const hasher& __hf, const key_equal& __eql,
424 const allocator_type& __a);
Marshall Clowbd444af2013-09-30 21:33:51425#if _LIBCPP_STD_VER > 11
426 inline _LIBCPP_INLINE_VISIBILITY
427 unordered_set(initializer_list<value_type> __il, size_type __n,
428 const allocator_type& __a)
429 : unordered_set(__il, __n, hasher(), key_equal(), __a) {}
430 inline _LIBCPP_INLINE_VISIBILITY
431 unordered_set(initializer_list<value_type> __il, size_type __n,
432 const hasher& __hf, const allocator_type& __a)
433 : unordered_set(__il, __n, __hf, key_equal(), __a) {}
434#endif
Howard Hinnante3e32912011-08-12 21:56:02435#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16436 // ~unordered_set() = default;
Howard Hinnant61aa6012011-07-01 19:24:36437 _LIBCPP_INLINE_VISIBILITY
438 unordered_set& operator=(const unordered_set& __u)
439 {
440 __table_ = __u.__table_;
441 return *this;
442 }
Howard Hinnant73d21a42010-09-04 23:28:19443#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Evgeniy Stepanov9341a8a2016-04-22 01:04:55444 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37445 unordered_set& operator=(unordered_set&& __u)
446 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16447#endif
Howard Hinnante3e32912011-08-12 21:56:02448#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Evgeniy Stepanov9341a8a2016-04-22 01:04:55449 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16450 unordered_set& operator=(initializer_list<value_type> __il);
Howard Hinnante3e32912011-08-12 21:56:02451#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16452
Howard Hinnantee6ccd02010-09-23 18:58:28453 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37454 allocator_type get_allocator() const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16455 {return allocator_type(__table_.__node_alloc());}
456
Howard Hinnantee6ccd02010-09-23 18:58:28457 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37458 bool empty() const _NOEXCEPT {return __table_.size() == 0;}
Howard Hinnantee6ccd02010-09-23 18:58:28459 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37460 size_type size() const _NOEXCEPT {return __table_.size();}
Howard Hinnantee6ccd02010-09-23 18:58:28461 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37462 size_type max_size() const _NOEXCEPT {return __table_.max_size();}
Howard Hinnantbc8d3f92010-05-11 19:42:16463
Howard Hinnantee6ccd02010-09-23 18:58:28464 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37465 iterator begin() _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28466 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37467 iterator end() _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:28468 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37469 const_iterator begin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28470 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37471 const_iterator end() const _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:28472 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37473 const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:28474 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37475 const_iterator cend() const _NOEXCEPT {return __table_.end();}
Howard Hinnantbc8d3f92010-05-11 19:42:16476
Howard Hinnant73d21a42010-09-04 23:28:19477#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantbc8d3f92010-05-11 19:42:16478 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:28479 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16480 pair<iterator, bool> emplace(_Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19481 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantbc8d3f92010-05-11 19:42:16482 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:28483 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant39213642013-07-23 22:01:58484#if _LIBCPP_DEBUG_LEVEL >= 2
485 iterator emplace_hint(const_iterator __p, _Args&&... __args)
486 {
487 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
488 "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not"
489 " referring to this unordered_set");
490 return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
491 }
492#else
Howard Hinnantbc8d3f92010-05-11 19:42:16493 iterator emplace_hint(const_iterator, _Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:19494 {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
Howard Hinnant39213642013-07-23 22:01:58495#endif
Howard Hinnant73d21a42010-09-04 23:28:19496#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantee6ccd02010-09-23 18:58:28497 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16498 pair<iterator, bool> insert(const value_type& __x)
499 {return __table_.__insert_unique(__x);}
Howard Hinnant73d21a42010-09-04 23:28:19500#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28501 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16502 pair<iterator, bool> insert(value_type&& __x)
Howard Hinnant0949eed2011-06-30 21:18:19503 {return __table_.__insert_unique(_VSTD::move(__x));}
Howard Hinnant73d21a42010-09-04 23:28:19504#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28505 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant39213642013-07-23 22:01:58506#if _LIBCPP_DEBUG_LEVEL >= 2
507 iterator insert(const_iterator __p, const value_type& __x)
508 {
509 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
510 "unordered_set::insert(const_iterator, const value_type&) called with an iterator not"
511 " referring to this unordered_set");
512 return insert(__x).first;
513 }
514#else
Howard Hinnantbc8d3f92010-05-11 19:42:16515 iterator insert(const_iterator, const value_type& __x)
516 {return insert(__x).first;}
Howard Hinnant39213642013-07-23 22:01:58517#endif
Howard Hinnant73d21a42010-09-04 23:28:19518#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:28519 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant39213642013-07-23 22:01:58520#if _LIBCPP_DEBUG_LEVEL >= 2
521 iterator insert(const_iterator __p, value_type&& __x)
522 {
523 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
524 "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
525 " referring to this unordered_set");
526 return insert(_VSTD::move(__x)).first;
527 }
528#else
Howard Hinnantbc8d3f92010-05-11 19:42:16529 iterator insert(const_iterator, value_type&& __x)
Howard Hinnant0949eed2011-06-30 21:18:19530 {return insert(_VSTD::move(__x)).first;}
Howard Hinnant39213642013-07-23 22:01:58531#endif
Howard Hinnant73d21a42010-09-04 23:28:19532#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16533 template <class _InputIterator>
Evgeniy Stepanov9341a8a2016-04-22 01:04:55534 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16535 void insert(_InputIterator __first, _InputIterator __last);
Howard Hinnante3e32912011-08-12 21:56:02536#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantee6ccd02010-09-23 18:58:28537 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16538 void insert(initializer_list<value_type> __il)
539 {insert(__il.begin(), __il.end());}
Howard Hinnante3e32912011-08-12 21:56:02540#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16541
Howard Hinnantee6ccd02010-09-23 18:58:28542 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16543 iterator erase(const_iterator __p) {return __table_.erase(__p);}
Howard Hinnantee6ccd02010-09-23 18:58:28544 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16545 size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28546 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16547 iterator erase(const_iterator __first, const_iterator __last)
548 {return __table_.erase(__first, __last);}
Howard Hinnantee6ccd02010-09-23 18:58:28549 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37550 void clear() _NOEXCEPT {__table_.clear();}
Howard Hinnantbc8d3f92010-05-11 19:42:16551
Howard Hinnantee6ccd02010-09-23 18:58:28552 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37553 void swap(unordered_set& __u)
554 _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
555 {__table_.swap(__u.__table_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16556
Howard Hinnantee6ccd02010-09-23 18:58:28557 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16558 hasher hash_function() const {return __table_.hash_function();}
Howard Hinnantee6ccd02010-09-23 18:58:28559 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16560 key_equal key_eq() const {return __table_.key_eq();}
561
Howard Hinnantee6ccd02010-09-23 18:58:28562 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16563 iterator find(const key_type& __k) {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28564 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16565 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28566 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16567 size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28568 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16569 pair<iterator, iterator> equal_range(const key_type& __k)
570 {return __table_.__equal_range_unique(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:28571 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16572 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
573 {return __table_.__equal_range_unique(__k);}
574
Howard Hinnantee6ccd02010-09-23 18:58:28575 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37576 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
Howard Hinnantee6ccd02010-09-23 18:58:28577 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37578 size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
Howard Hinnantbc8d3f92010-05-11 19:42:16579
Howard Hinnantee6ccd02010-09-23 18:58:28580 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16581 size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28582 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16583 size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
584
Howard Hinnantee6ccd02010-09-23 18:58:28585 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16586 local_iterator begin(size_type __n) {return __table_.begin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28587 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16588 local_iterator end(size_type __n) {return __table_.end(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28589 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16590 const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28591 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16592 const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28593 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16594 const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28595 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16596 const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
597
Howard Hinnantee6ccd02010-09-23 18:58:28598 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37599 float load_factor() const _NOEXCEPT {return __table_.load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:28600 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37601 float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:28602 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16603 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
Howard Hinnantee6ccd02010-09-23 18:58:28604 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16605 void rehash(size_type __n) {__table_.rehash(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:28606 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16607 void reserve(size_type __n) {__table_.reserve(__n);}
Howard Hinnant39213642013-07-23 22:01:58608
609#if _LIBCPP_DEBUG_LEVEL >= 2
610
611 bool __dereferenceable(const const_iterator* __i) const
612 {return __table_.__dereferenceable(__i);}
613 bool __decrementable(const const_iterator* __i) const
614 {return __table_.__decrementable(__i);}
615 bool __addable(const const_iterator* __i, ptrdiff_t __n) const
616 {return __table_.__addable(__i, __n);}
617 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
618 {return __table_.__addable(__i, __n);}
619
620#endif // _LIBCPP_DEBUG_LEVEL >= 2
621
Howard Hinnantbc8d3f92010-05-11 19:42:16622};
623
624template <class _Value, class _Hash, class _Pred, class _Alloc>
625unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
626 const hasher& __hf, const key_equal& __eql)
627 : __table_(__hf, __eql)
628{
Howard Hinnant39213642013-07-23 22:01:58629#if _LIBCPP_DEBUG_LEVEL >= 2
630 __get_db()->__insert_c(this);
631#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16632 __table_.rehash(__n);
633}
634
635template <class _Value, class _Hash, class _Pred, class _Alloc>
636unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
637 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
638 : __table_(__hf, __eql, __a)
639{
Howard Hinnant39213642013-07-23 22:01:58640#if _LIBCPP_DEBUG_LEVEL >= 2
641 __get_db()->__insert_c(this);
642#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16643 __table_.rehash(__n);
644}
645
646template <class _Value, class _Hash, class _Pred, class _Alloc>
647template <class _InputIterator>
648unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
649 _InputIterator __first, _InputIterator __last)
650{
Howard Hinnant39213642013-07-23 22:01:58651#if _LIBCPP_DEBUG_LEVEL >= 2
652 __get_db()->__insert_c(this);
653#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16654 insert(__first, __last);
655}
656
657template <class _Value, class _Hash, class _Pred, class _Alloc>
658template <class _InputIterator>
659unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
660 _InputIterator __first, _InputIterator __last, size_type __n,
661 const hasher& __hf, const key_equal& __eql)
662 : __table_(__hf, __eql)
663{
Howard Hinnant39213642013-07-23 22:01:58664#if _LIBCPP_DEBUG_LEVEL >= 2
665 __get_db()->__insert_c(this);
666#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16667 __table_.rehash(__n);
668 insert(__first, __last);
669}
670
671template <class _Value, class _Hash, class _Pred, class _Alloc>
672template <class _InputIterator>
673unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
674 _InputIterator __first, _InputIterator __last, size_type __n,
675 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
676 : __table_(__hf, __eql, __a)
677{
Howard Hinnant39213642013-07-23 22:01:58678#if _LIBCPP_DEBUG_LEVEL >= 2
679 __get_db()->__insert_c(this);
680#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16681 __table_.rehash(__n);
682 insert(__first, __last);
683}
684
685template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanov9341a8a2016-04-22 01:04:55686inline
Howard Hinnantbc8d3f92010-05-11 19:42:16687unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
688 const allocator_type& __a)
689 : __table_(__a)
690{
Howard Hinnant39213642013-07-23 22:01:58691#if _LIBCPP_DEBUG_LEVEL >= 2
692 __get_db()->__insert_c(this);
693#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16694}
695
696template <class _Value, class _Hash, class _Pred, class _Alloc>
697unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
698 const unordered_set& __u)
699 : __table_(__u.__table_)
700{
Howard Hinnant39213642013-07-23 22:01:58701#if _LIBCPP_DEBUG_LEVEL >= 2
702 __get_db()->__insert_c(this);
703#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16704 __table_.rehash(__u.bucket_count());
705 insert(__u.begin(), __u.end());
706}
707
708template <class _Value, class _Hash, class _Pred, class _Alloc>
709unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
710 const unordered_set& __u, const allocator_type& __a)
711 : __table_(__u.__table_, __a)
712{
Howard Hinnant39213642013-07-23 22:01:58713#if _LIBCPP_DEBUG_LEVEL >= 2
714 __get_db()->__insert_c(this);
715#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16716 __table_.rehash(__u.bucket_count());
717 insert(__u.begin(), __u.end());
718}
719
Howard Hinnant73d21a42010-09-04 23:28:19720#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16721
722template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanov9341a8a2016-04-22 01:04:55723inline
Howard Hinnantbc8d3f92010-05-11 19:42:16724unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
725 unordered_set&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:37726 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
Howard Hinnant0949eed2011-06-30 21:18:19727 : __table_(_VSTD::move(__u.__table_))
Howard Hinnantbc8d3f92010-05-11 19:42:16728{
Howard Hinnant39213642013-07-23 22:01:58729#if _LIBCPP_DEBUG_LEVEL >= 2
730 __get_db()->__insert_c(this);
731 __get_db()->swap(this, &__u);
732#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16733}
734
735template <class _Value, class _Hash, class _Pred, class _Alloc>
736unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
737 unordered_set&& __u, const allocator_type& __a)
Howard Hinnant0949eed2011-06-30 21:18:19738 : __table_(_VSTD::move(__u.__table_), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:16739{
Howard Hinnant39213642013-07-23 22:01:58740#if _LIBCPP_DEBUG_LEVEL >= 2
741 __get_db()->__insert_c(this);
742#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16743 if (__a != __u.get_allocator())
744 {
745 iterator __i = __u.begin();
746 while (__u.size() != 0)
Howard Hinnant0949eed2011-06-30 21:18:19747 __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
Howard Hinnantbc8d3f92010-05-11 19:42:16748 }
Howard Hinnant39213642013-07-23 22:01:58749#if _LIBCPP_DEBUG_LEVEL >= 2
750 else
751 __get_db()->swap(this, &__u);
752#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16753}
754
Howard Hinnant73d21a42010-09-04 23:28:19755#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16756
Howard Hinnante3e32912011-08-12 21:56:02757#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
758
Howard Hinnantbc8d3f92010-05-11 19:42:16759template <class _Value, class _Hash, class _Pred, class _Alloc>
760unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
761 initializer_list<value_type> __il)
762{
Howard Hinnant39213642013-07-23 22:01:58763#if _LIBCPP_DEBUG_LEVEL >= 2
764 __get_db()->__insert_c(this);
765#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16766 insert(__il.begin(), __il.end());
767}
768
769template <class _Value, class _Hash, class _Pred, class _Alloc>
770unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
771 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
772 const key_equal& __eql)
773 : __table_(__hf, __eql)
774{
Howard Hinnant39213642013-07-23 22:01:58775#if _LIBCPP_DEBUG_LEVEL >= 2
776 __get_db()->__insert_c(this);
777#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16778 __table_.rehash(__n);
779 insert(__il.begin(), __il.end());
780}
781
782template <class _Value, class _Hash, class _Pred, class _Alloc>
783unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
784 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
785 const key_equal& __eql, const allocator_type& __a)
786 : __table_(__hf, __eql, __a)
787{
Howard Hinnant39213642013-07-23 22:01:58788#if _LIBCPP_DEBUG_LEVEL >= 2
789 __get_db()->__insert_c(this);
790#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16791 __table_.rehash(__n);
792 insert(__il.begin(), __il.end());
793}
794
Howard Hinnante3e32912011-08-12 21:56:02795#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
796
Howard Hinnant73d21a42010-09-04 23:28:19797#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16798
799template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanov9341a8a2016-04-22 01:04:55800inline
Howard Hinnantbc8d3f92010-05-11 19:42:16801unordered_set<_Value, _Hash, _Pred, _Alloc>&
802unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:37803 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:16804{
Howard Hinnant0949eed2011-06-30 21:18:19805 __table_ = _VSTD::move(__u.__table_);
Howard Hinnantbc8d3f92010-05-11 19:42:16806 return *this;
807}
808
Howard Hinnant73d21a42010-09-04 23:28:19809#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16810
Howard Hinnante3e32912011-08-12 21:56:02811#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
812
Howard Hinnantbc8d3f92010-05-11 19:42:16813template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanov9341a8a2016-04-22 01:04:55814inline
Howard Hinnantbc8d3f92010-05-11 19:42:16815unordered_set<_Value, _Hash, _Pred, _Alloc>&
816unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
817 initializer_list<value_type> __il)
818{
819 __table_.__assign_unique(__il.begin(), __il.end());
820 return *this;
821}
822
Howard Hinnante3e32912011-08-12 21:56:02823#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
824
Howard Hinnantbc8d3f92010-05-11 19:42:16825template <class _Value, class _Hash, class _Pred, class _Alloc>
826template <class _InputIterator>
Evgeniy Stepanov9341a8a2016-04-22 01:04:55827inline
Howard Hinnantbc8d3f92010-05-11 19:42:16828void
829unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
830 _InputIterator __last)
831{
832 for (; __first != __last; ++__first)
833 __table_.__insert_unique(*__first);
834}
835
836template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28837inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16838void
839swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
840 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
Howard Hinnant04dae1d2011-06-04 20:18:37841 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantbc8d3f92010-05-11 19:42:16842{
843 __x.swap(__y);
844}
845
846template <class _Value, class _Hash, class _Pred, class _Alloc>
847bool
848operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
849 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
850{
851 if (__x.size() != __y.size())
852 return false;
853 typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
854 const_iterator;
855 for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
856 __i != __ex; ++__i)
857 {
858 const_iterator __j = __y.find(*__i);
859 if (__j == __ey || !(*__i == *__j))
860 return false;
861 }
862 return true;
863}
864
865template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:28866inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16867bool
868operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
869 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
870{
871 return !(__x == __y);
872}
873
874template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
875 class _Alloc = allocator<_Value> >
Eric Fiselierc3589a82017-01-04 23:56:00876class _LIBCPP_TEMPLATE_VIS unordered_multiset
Howard Hinnantbc8d3f92010-05-11 19:42:16877{
878public:
879 // types
880 typedef _Value key_type;
881 typedef key_type value_type;
882 typedef _Hash hasher;
883 typedef _Pred key_equal;
884 typedef _Alloc allocator_type;
885 typedef value_type& reference;
886 typedef const value_type& const_reference;
Howard Hinnant39213642013-07-23 22:01:58887 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
888 "Invalid allocator::value_type");
Howard Hinnantbc8d3f92010-05-11 19:42:16889
890private:
891 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
892
893 __table __table_;
894
895public:
896 typedef typename __table::pointer pointer;
897 typedef typename __table::const_pointer const_pointer;
898 typedef typename __table::size_type size_type;
899 typedef typename __table::difference_type difference_type;
900
901 typedef typename __table::const_iterator iterator;
902 typedef typename __table::const_iterator const_iterator;
903 typedef typename __table::const_local_iterator local_iterator;
904 typedef typename __table::const_local_iterator const_local_iterator;
905
Howard Hinnantee6ccd02010-09-23 18:58:28906 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37907 unordered_multiset()
908 _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
Howard Hinnant39213642013-07-23 22:01:58909 {
910#if _LIBCPP_DEBUG_LEVEL >= 2
911 __get_db()->__insert_c(this);
912#endif
913 }
Howard Hinnantbc8d3f92010-05-11 19:42:16914 explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(),
915 const key_equal& __eql = key_equal());
916 unordered_multiset(size_type __n, const hasher& __hf,
917 const key_equal& __eql, const allocator_type& __a);
Marshall Clowbd444af2013-09-30 21:33:51918#if _LIBCPP_STD_VER > 11
919 inline _LIBCPP_INLINE_VISIBILITY
920 unordered_multiset(size_type __n, const allocator_type& __a)
921 : unordered_multiset(__n, hasher(), key_equal(), __a) {}
922 inline _LIBCPP_INLINE_VISIBILITY
923 unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
924 : unordered_multiset(__n, __hf, key_equal(), __a) {}
925#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16926 template <class _InputIterator>
927 unordered_multiset(_InputIterator __first, _InputIterator __last);
928 template <class _InputIterator>
929 unordered_multiset(_InputIterator __first, _InputIterator __last,
930 size_type __n, const hasher& __hf = hasher(),
931 const key_equal& __eql = key_equal());
932 template <class _InputIterator>
933 unordered_multiset(_InputIterator __first, _InputIterator __last,
934 size_type __n , const hasher& __hf,
935 const key_equal& __eql, const allocator_type& __a);
Marshall Clowbd444af2013-09-30 21:33:51936#if _LIBCPP_STD_VER > 11
937 template <class _InputIterator>
938 inline _LIBCPP_INLINE_VISIBILITY
939 unordered_multiset(_InputIterator __first, _InputIterator __last,
940 size_type __n, const allocator_type& __a)
941 : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {}
942 template <class _InputIterator>
943 inline _LIBCPP_INLINE_VISIBILITY
944 unordered_multiset(_InputIterator __first, _InputIterator __last,
945 size_type __n, const hasher& __hf, const allocator_type& __a)
946 : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
947#endif
Evgeniy Stepanov9341a8a2016-04-22 01:04:55948 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16949 explicit unordered_multiset(const allocator_type& __a);
950 unordered_multiset(const unordered_multiset& __u);
951 unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19952#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Evgeniy Stepanov9341a8a2016-04-22 01:04:55953 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37954 unordered_multiset(unordered_multiset&& __u)
955 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16956 unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
Howard Hinnant73d21a42010-09-04 23:28:19957#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnante3e32912011-08-12 21:56:02958#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16959 unordered_multiset(initializer_list<value_type> __il);
960 unordered_multiset(initializer_list<value_type> __il, size_type __n,
961 const hasher& __hf = hasher(),
962 const key_equal& __eql = key_equal());
963 unordered_multiset(initializer_list<value_type> __il, size_type __n,
964 const hasher& __hf, const key_equal& __eql,
965 const allocator_type& __a);
Marshall Clowbd444af2013-09-30 21:33:51966#if _LIBCPP_STD_VER > 11
967 inline _LIBCPP_INLINE_VISIBILITY
968 unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
969 : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
970 inline _LIBCPP_INLINE_VISIBILITY
971 unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
972 : unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
973#endif
Howard Hinnante3e32912011-08-12 21:56:02974#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16975 // ~unordered_multiset() = default;
Howard Hinnant61aa6012011-07-01 19:24:36976 _LIBCPP_INLINE_VISIBILITY
977 unordered_multiset& operator=(const unordered_multiset& __u)
978 {
979 __table_ = __u.__table_;
980 return *this;
981 }
Howard Hinnant73d21a42010-09-04 23:28:19982#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Evgeniy Stepanov9341a8a2016-04-22 01:04:55983 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37984 unordered_multiset& operator=(unordered_multiset&& __u)
985 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
Howard Hinnantbc8d3f92010-05-11 19:42:16986#endif
Howard Hinnante3e32912011-08-12 21:56:02987#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16988 unordered_multiset& operator=(initializer_list<value_type> __il);
Howard Hinnante3e32912011-08-12 21:56:02989#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16990
Howard Hinnantee6ccd02010-09-23 18:58:28991 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37992 allocator_type get_allocator() const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16993 {return allocator_type(__table_.__node_alloc());}
994
Howard Hinnantee6ccd02010-09-23 18:58:28995 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37996 bool empty() const _NOEXCEPT {return __table_.size() == 0;}
Howard Hinnantee6ccd02010-09-23 18:58:28997 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:37998 size_type size() const _NOEXCEPT {return __table_.size();}
Howard Hinnantee6ccd02010-09-23 18:58:28999 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371000 size_type max_size() const _NOEXCEPT {return __table_.max_size();}
Howard Hinnantbc8d3f92010-05-11 19:42:161001
Howard Hinnantee6ccd02010-09-23 18:58:281002 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371003 iterator begin() _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:281004 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371005 iterator end() _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:281006 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371007 const_iterator begin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:281008 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371009 const_iterator end() const _NOEXCEPT {return __table_.end();}
Howard Hinnantee6ccd02010-09-23 18:58:281010 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371011 const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
Howard Hinnantee6ccd02010-09-23 18:58:281012 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371013 const_iterator cend() const _NOEXCEPT {return __table_.end();}
Howard Hinnantbc8d3f92010-05-11 19:42:161014
Howard Hinnant73d21a42010-09-04 23:28:191015#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantbc8d3f92010-05-11 19:42:161016 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:281017 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161018 iterator emplace(_Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:191019 {return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
Howard Hinnantbc8d3f92010-05-11 19:42:161020 template <class... _Args>
Howard Hinnantee6ccd02010-09-23 18:58:281021 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161022 iterator emplace_hint(const_iterator __p, _Args&&... __args)
Howard Hinnant0949eed2011-06-30 21:18:191023 {return __table_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
Howard Hinnant73d21a42010-09-04 23:28:191024#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Howard Hinnantee6ccd02010-09-23 18:58:281025 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161026 iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
Howard Hinnant73d21a42010-09-04 23:28:191027#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:281028 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant0949eed2011-06-30 21:18:191029 iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
Howard Hinnantbc8d3f92010-05-11 19:42:161030#endif
Howard Hinnantee6ccd02010-09-23 18:58:281031 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161032 iterator insert(const_iterator __p, const value_type& __x)
1033 {return __table_.__insert_multi(__p, __x);}
Howard Hinnant73d21a42010-09-04 23:28:191034#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantee6ccd02010-09-23 18:58:281035 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161036 iterator insert(const_iterator __p, value_type&& __x)
Howard Hinnant0949eed2011-06-30 21:18:191037 {return __table_.__insert_multi(__p, _VSTD::move(__x));}
Howard Hinnant73d21a42010-09-04 23:28:191038#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:161039 template <class _InputIterator>
Evgeniy Stepanov9341a8a2016-04-22 01:04:551040 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161041 void insert(_InputIterator __first, _InputIterator __last);
Howard Hinnante3e32912011-08-12 21:56:021042#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantee6ccd02010-09-23 18:58:281043 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161044 void insert(initializer_list<value_type> __il)
1045 {insert(__il.begin(), __il.end());}
Howard Hinnante3e32912011-08-12 21:56:021046#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:161047
Howard Hinnantee6ccd02010-09-23 18:58:281048 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161049 iterator erase(const_iterator __p) {return __table_.erase(__p);}
Howard Hinnantee6ccd02010-09-23 18:58:281050 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161051 size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:281052 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161053 iterator erase(const_iterator __first, const_iterator __last)
1054 {return __table_.erase(__first, __last);}
Howard Hinnantee6ccd02010-09-23 18:58:281055 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371056 void clear() _NOEXCEPT {__table_.clear();}
Howard Hinnantbc8d3f92010-05-11 19:42:161057
Howard Hinnantee6ccd02010-09-23 18:58:281058 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371059 void swap(unordered_multiset& __u)
1060 _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
1061 {__table_.swap(__u.__table_);}
Howard Hinnantbc8d3f92010-05-11 19:42:161062
Howard Hinnantee6ccd02010-09-23 18:58:281063 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161064 hasher hash_function() const {return __table_.hash_function();}
Howard Hinnantee6ccd02010-09-23 18:58:281065 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161066 key_equal key_eq() const {return __table_.key_eq();}
1067
Howard Hinnantee6ccd02010-09-23 18:58:281068 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161069 iterator find(const key_type& __k) {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:281070 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161071 const_iterator find(const key_type& __k) const {return __table_.find(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:281072 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161073 size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:281074 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161075 pair<iterator, iterator> equal_range(const key_type& __k)
1076 {return __table_.__equal_range_multi(__k);}
Howard Hinnantee6ccd02010-09-23 18:58:281077 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161078 pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
1079 {return __table_.__equal_range_multi(__k);}
1080
Howard Hinnantee6ccd02010-09-23 18:58:281081 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371082 size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
Howard Hinnantee6ccd02010-09-23 18:58:281083 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371084 size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
Howard Hinnantbc8d3f92010-05-11 19:42:161085
Howard Hinnantee6ccd02010-09-23 18:58:281086 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161087 size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:281088 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161089 size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
1090
Howard Hinnantee6ccd02010-09-23 18:58:281091 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161092 local_iterator begin(size_type __n) {return __table_.begin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:281093 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161094 local_iterator end(size_type __n) {return __table_.end(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:281095 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161096 const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:281097 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161098 const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:281099 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161100 const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:281101 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161102 const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
1103
Howard Hinnantee6ccd02010-09-23 18:58:281104 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371105 float load_factor() const _NOEXCEPT {return __table_.load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:281106 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant04dae1d2011-06-04 20:18:371107 float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
Howard Hinnantee6ccd02010-09-23 18:58:281108 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161109 void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
Howard Hinnantee6ccd02010-09-23 18:58:281110 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161111 void rehash(size_type __n) {__table_.rehash(__n);}
Howard Hinnantee6ccd02010-09-23 18:58:281112 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161113 void reserve(size_type __n) {__table_.reserve(__n);}
Howard Hinnant39213642013-07-23 22:01:581114
1115#if _LIBCPP_DEBUG_LEVEL >= 2
1116
1117 bool __dereferenceable(const const_iterator* __i) const
1118 {return __table_.__dereferenceable(__i);}
1119 bool __decrementable(const const_iterator* __i) const
1120 {return __table_.__decrementable(__i);}
1121 bool __addable(const const_iterator* __i, ptrdiff_t __n) const
1122 {return __table_.__addable(__i, __n);}
1123 bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
1124 {return __table_.__addable(__i, __n);}
1125
1126#endif // _LIBCPP_DEBUG_LEVEL >= 2
1127
Howard Hinnantbc8d3f92010-05-11 19:42:161128};
1129
1130template <class _Value, class _Hash, class _Pred, class _Alloc>
1131unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1132 size_type __n, const hasher& __hf, const key_equal& __eql)
1133 : __table_(__hf, __eql)
1134{
Howard Hinnant39213642013-07-23 22:01:581135#if _LIBCPP_DEBUG_LEVEL >= 2
1136 __get_db()->__insert_c(this);
1137#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161138 __table_.rehash(__n);
1139}
1140
1141template <class _Value, class _Hash, class _Pred, class _Alloc>
1142unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1143 size_type __n, const hasher& __hf, const key_equal& __eql,
1144 const allocator_type& __a)
1145 : __table_(__hf, __eql, __a)
1146{
Howard Hinnant39213642013-07-23 22:01:581147#if _LIBCPP_DEBUG_LEVEL >= 2
1148 __get_db()->__insert_c(this);
1149#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161150 __table_.rehash(__n);
1151}
1152
1153template <class _Value, class _Hash, class _Pred, class _Alloc>
1154template <class _InputIterator>
1155unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1156 _InputIterator __first, _InputIterator __last)
1157{
Howard Hinnant39213642013-07-23 22:01:581158#if _LIBCPP_DEBUG_LEVEL >= 2
1159 __get_db()->__insert_c(this);
1160#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161161 insert(__first, __last);
1162}
1163
1164template <class _Value, class _Hash, class _Pred, class _Alloc>
1165template <class _InputIterator>
1166unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1167 _InputIterator __first, _InputIterator __last, size_type __n,
1168 const hasher& __hf, const key_equal& __eql)
1169 : __table_(__hf, __eql)
1170{
Howard Hinnant39213642013-07-23 22:01:581171#if _LIBCPP_DEBUG_LEVEL >= 2
1172 __get_db()->__insert_c(this);
1173#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161174 __table_.rehash(__n);
1175 insert(__first, __last);
1176}
1177
1178template <class _Value, class _Hash, class _Pred, class _Alloc>
1179template <class _InputIterator>
1180unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1181 _InputIterator __first, _InputIterator __last, size_type __n,
1182 const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
1183 : __table_(__hf, __eql, __a)
1184{
Howard Hinnant39213642013-07-23 22:01:581185#if _LIBCPP_DEBUG_LEVEL >= 2
1186 __get_db()->__insert_c(this);
1187#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161188 __table_.rehash(__n);
1189 insert(__first, __last);
1190}
1191
1192template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanov9341a8a2016-04-22 01:04:551193inline
Howard Hinnantbc8d3f92010-05-11 19:42:161194unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1195 const allocator_type& __a)
1196 : __table_(__a)
1197{
Howard Hinnant39213642013-07-23 22:01:581198#if _LIBCPP_DEBUG_LEVEL >= 2
1199 __get_db()->__insert_c(this);
1200#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161201}
1202
1203template <class _Value, class _Hash, class _Pred, class _Alloc>
1204unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1205 const unordered_multiset& __u)
1206 : __table_(__u.__table_)
1207{
Howard Hinnant39213642013-07-23 22:01:581208#if _LIBCPP_DEBUG_LEVEL >= 2
1209 __get_db()->__insert_c(this);
1210#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161211 __table_.rehash(__u.bucket_count());
1212 insert(__u.begin(), __u.end());
1213}
1214
1215template <class _Value, class _Hash, class _Pred, class _Alloc>
1216unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1217 const unordered_multiset& __u, const allocator_type& __a)
1218 : __table_(__u.__table_, __a)
1219{
Howard Hinnant39213642013-07-23 22:01:581220#if _LIBCPP_DEBUG_LEVEL >= 2
1221 __get_db()->__insert_c(this);
1222#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161223 __table_.rehash(__u.bucket_count());
1224 insert(__u.begin(), __u.end());
1225}
1226
Howard Hinnant73d21a42010-09-04 23:28:191227#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:161228
1229template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanov9341a8a2016-04-22 01:04:551230inline
Howard Hinnantbc8d3f92010-05-11 19:42:161231unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1232 unordered_multiset&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:371233 _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
Howard Hinnant0949eed2011-06-30 21:18:191234 : __table_(_VSTD::move(__u.__table_))
Howard Hinnantbc8d3f92010-05-11 19:42:161235{
Howard Hinnant39213642013-07-23 22:01:581236#if _LIBCPP_DEBUG_LEVEL >= 2
1237 __get_db()->__insert_c(this);
1238 __get_db()->swap(this, &__u);
1239#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161240}
1241
1242template <class _Value, class _Hash, class _Pred, class _Alloc>
1243unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1244 unordered_multiset&& __u, const allocator_type& __a)
Howard Hinnant0949eed2011-06-30 21:18:191245 : __table_(_VSTD::move(__u.__table_), __a)
Howard Hinnantbc8d3f92010-05-11 19:42:161246{
Howard Hinnant39213642013-07-23 22:01:581247#if _LIBCPP_DEBUG_LEVEL >= 2
1248 __get_db()->__insert_c(this);
1249#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161250 if (__a != __u.get_allocator())
1251 {
1252 iterator __i = __u.begin();
1253 while (__u.size() != 0)
Howard Hinnant0949eed2011-06-30 21:18:191254 __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
Howard Hinnantbc8d3f92010-05-11 19:42:161255 }
Howard Hinnant39213642013-07-23 22:01:581256#if _LIBCPP_DEBUG_LEVEL >= 2
1257 else
1258 __get_db()->swap(this, &__u);
1259#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161260}
1261
Howard Hinnant73d21a42010-09-04 23:28:191262#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:161263
Howard Hinnante3e32912011-08-12 21:56:021264#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1265
Howard Hinnantbc8d3f92010-05-11 19:42:161266template <class _Value, class _Hash, class _Pred, class _Alloc>
1267unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1268 initializer_list<value_type> __il)
1269{
Howard Hinnant39213642013-07-23 22:01:581270#if _LIBCPP_DEBUG_LEVEL >= 2
1271 __get_db()->__insert_c(this);
1272#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161273 insert(__il.begin(), __il.end());
1274}
1275
1276template <class _Value, class _Hash, class _Pred, class _Alloc>
1277unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1278 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1279 const key_equal& __eql)
1280 : __table_(__hf, __eql)
1281{
Howard Hinnant39213642013-07-23 22:01:581282#if _LIBCPP_DEBUG_LEVEL >= 2
1283 __get_db()->__insert_c(this);
1284#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161285 __table_.rehash(__n);
1286 insert(__il.begin(), __il.end());
1287}
1288
1289template <class _Value, class _Hash, class _Pred, class _Alloc>
1290unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1291 initializer_list<value_type> __il, size_type __n, const hasher& __hf,
1292 const key_equal& __eql, const allocator_type& __a)
1293 : __table_(__hf, __eql, __a)
1294{
Howard Hinnant39213642013-07-23 22:01:581295#if _LIBCPP_DEBUG_LEVEL >= 2
1296 __get_db()->__insert_c(this);
1297#endif
Howard Hinnantbc8d3f92010-05-11 19:42:161298 __table_.rehash(__n);
1299 insert(__il.begin(), __il.end());
1300}
1301
Howard Hinnante3e32912011-08-12 21:56:021302#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1303
Howard Hinnant73d21a42010-09-04 23:28:191304#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:161305
1306template <class _Value, class _Hash, class _Pred, class _Alloc>
Evgeniy Stepanov9341a8a2016-04-22 01:04:551307inline
Howard Hinnantbc8d3f92010-05-11 19:42:161308unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1309unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
1310 unordered_multiset&& __u)
Howard Hinnant04dae1d2011-06-04 20:18:371311 _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
Howard Hinnantbc8d3f92010-05-11 19:42:161312{
Howard Hinnant0949eed2011-06-30 21:18:191313 __table_ = _VSTD::move(__u.__table_);
Howard Hinnantbc8d3f92010-05-11 19:42:161314 return *this;
1315}
1316
Howard Hinnant73d21a42010-09-04 23:28:191317#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:161318
Howard Hinnante3e32912011-08-12 21:56:021319#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1320
Howard Hinnantbc8d3f92010-05-11 19:42:161321template <class _Value, class _Hash, class _Pred, class _Alloc>
1322inline
1323unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
1324unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
1325 initializer_list<value_type> __il)
1326{
1327 __table_.__assign_multi(__il.begin(), __il.end());
1328 return *this;
1329}
1330
Howard Hinnante3e32912011-08-12 21:56:021331#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
1332
Howard Hinnantbc8d3f92010-05-11 19:42:161333template <class _Value, class _Hash, class _Pred, class _Alloc>
1334template <class _InputIterator>
Evgeniy Stepanov9341a8a2016-04-22 01:04:551335inline
Howard Hinnantbc8d3f92010-05-11 19:42:161336void
1337unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
1338 _InputIterator __last)
1339{
1340 for (; __first != __last; ++__first)
1341 __table_.__insert_multi(*__first);
1342}
1343
1344template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:281345inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161346void
1347swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1348 unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
Howard Hinnant04dae1d2011-06-04 20:18:371349 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantbc8d3f92010-05-11 19:42:161350{
1351 __x.swap(__y);
1352}
1353
1354template <class _Value, class _Hash, class _Pred, class _Alloc>
1355bool
1356operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1357 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1358{
1359 if (__x.size() != __y.size())
1360 return false;
1361 typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
1362 const_iterator;
1363 typedef pair<const_iterator, const_iterator> _EqRng;
1364 for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
1365 {
1366 _EqRng __xeq = __x.equal_range(*__i);
1367 _EqRng __yeq = __y.equal_range(*__i);
Howard Hinnant0949eed2011-06-30 21:18:191368 if (_VSTD::distance(__xeq.first, __xeq.second) !=
1369 _VSTD::distance(__yeq.first, __yeq.second) ||
1370 !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
Howard Hinnantbc8d3f92010-05-11 19:42:161371 return false;
1372 __i = __xeq.second;
1373 }
1374 return true;
1375}
1376
1377template <class _Value, class _Hash, class _Pred, class _Alloc>
Howard Hinnantee6ccd02010-09-23 18:58:281378inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:161379bool
1380operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1381 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1382{
1383 return !(__x == __y);
1384}
1385
1386_LIBCPP_END_NAMESPACE_STD
1387
1388#endif // _LIBCPP_UNORDERED_SET