Chris@16
|
1
|
Chris@16
|
2 // Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard.
|
Chris@16
|
3 // Copyright (C) 2005-2011 Daniel James.
|
Chris@16
|
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6
|
Chris@16
|
7 // See http://www.boost.org/libs/unordered for documentation
|
Chris@16
|
8
|
Chris@16
|
9 #ifndef BOOST_UNORDERED_UNORDERED_SET_HPP_INCLUDED
|
Chris@16
|
10 #define BOOST_UNORDERED_UNORDERED_SET_HPP_INCLUDED
|
Chris@16
|
11
|
Chris@101
|
12 #include <boost/config.hpp>
|
Chris@101
|
13 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@101
|
14 #pragma once
|
Chris@16
|
15 #endif
|
Chris@16
|
16
|
Chris@16
|
17 #include <boost/unordered/unordered_set_fwd.hpp>
|
Chris@16
|
18 #include <boost/unordered/detail/equivalent.hpp>
|
Chris@16
|
19 #include <boost/unordered/detail/unique.hpp>
|
Chris@16
|
20 #include <boost/unordered/detail/util.hpp>
|
Chris@16
|
21 #include <boost/functional/hash.hpp>
|
Chris@16
|
22 #include <boost/move/move.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
Chris@16
|
25 #include <initializer_list>
|
Chris@16
|
26 #endif
|
Chris@16
|
27
|
Chris@16
|
28 #if defined(BOOST_MSVC)
|
Chris@16
|
29 #pragma warning(push)
|
Chris@16
|
30 #if BOOST_MSVC >= 1400
|
Chris@16
|
31 #pragma warning(disable:4396) //the inline specifier cannot be used when a
|
Chris@16
|
32 // friend declaration refers to a specialization
|
Chris@16
|
33 // of a function template
|
Chris@16
|
34 #endif
|
Chris@16
|
35 #endif
|
Chris@16
|
36
|
Chris@16
|
37 namespace boost
|
Chris@16
|
38 {
|
Chris@16
|
39 namespace unordered
|
Chris@16
|
40 {
|
Chris@16
|
41 template <class T, class H, class P, class A>
|
Chris@16
|
42 class unordered_set
|
Chris@16
|
43 {
|
Chris@16
|
44 #if defined(BOOST_UNORDERED_USE_MOVE)
|
Chris@16
|
45 BOOST_COPYABLE_AND_MOVABLE(unordered_set)
|
Chris@16
|
46 #endif
|
Chris@16
|
47 public:
|
Chris@16
|
48
|
Chris@16
|
49 typedef T key_type;
|
Chris@16
|
50 typedef T value_type;
|
Chris@16
|
51 typedef H hasher;
|
Chris@16
|
52 typedef P key_equal;
|
Chris@16
|
53 typedef A allocator_type;
|
Chris@16
|
54
|
Chris@16
|
55 private:
|
Chris@16
|
56
|
Chris@16
|
57 typedef boost::unordered::detail::set<A, T, H, P> types;
|
Chris@16
|
58 typedef typename types::traits allocator_traits;
|
Chris@16
|
59 typedef typename types::table table;
|
Chris@16
|
60
|
Chris@16
|
61 public:
|
Chris@16
|
62
|
Chris@16
|
63 typedef typename allocator_traits::pointer pointer;
|
Chris@16
|
64 typedef typename allocator_traits::const_pointer const_pointer;
|
Chris@16
|
65
|
Chris@16
|
66 typedef value_type& reference;
|
Chris@16
|
67 typedef value_type const& const_reference;
|
Chris@16
|
68
|
Chris@16
|
69 typedef std::size_t size_type;
|
Chris@16
|
70 typedef std::ptrdiff_t difference_type;
|
Chris@16
|
71
|
Chris@16
|
72 typedef typename table::cl_iterator const_local_iterator;
|
Chris@16
|
73 typedef typename table::cl_iterator local_iterator;
|
Chris@16
|
74 typedef typename table::c_iterator const_iterator;
|
Chris@16
|
75 typedef typename table::c_iterator iterator;
|
Chris@16
|
76
|
Chris@16
|
77 private:
|
Chris@16
|
78
|
Chris@16
|
79 table table_;
|
Chris@16
|
80
|
Chris@16
|
81 public:
|
Chris@16
|
82
|
Chris@16
|
83 // constructors
|
Chris@16
|
84
|
Chris@16
|
85 explicit unordered_set(
|
Chris@16
|
86 size_type = boost::unordered::detail::default_bucket_count,
|
Chris@16
|
87 const hasher& = hasher(),
|
Chris@16
|
88 const key_equal& = key_equal(),
|
Chris@16
|
89 const allocator_type& = allocator_type());
|
Chris@16
|
90
|
Chris@16
|
91 explicit unordered_set(allocator_type const&);
|
Chris@16
|
92
|
Chris@16
|
93 template <class InputIt>
|
Chris@16
|
94 unordered_set(InputIt, InputIt);
|
Chris@16
|
95
|
Chris@16
|
96 template <class InputIt>
|
Chris@16
|
97 unordered_set(
|
Chris@16
|
98 InputIt, InputIt,
|
Chris@16
|
99 size_type,
|
Chris@16
|
100 const hasher& = hasher(),
|
Chris@16
|
101 const key_equal& = key_equal());
|
Chris@16
|
102
|
Chris@16
|
103 template <class InputIt>
|
Chris@16
|
104 unordered_set(
|
Chris@16
|
105 InputIt, InputIt,
|
Chris@16
|
106 size_type,
|
Chris@16
|
107 const hasher&,
|
Chris@16
|
108 const key_equal&,
|
Chris@16
|
109 const allocator_type&);
|
Chris@16
|
110
|
Chris@16
|
111 // copy/move constructors
|
Chris@16
|
112
|
Chris@16
|
113 unordered_set(unordered_set const&);
|
Chris@16
|
114
|
Chris@16
|
115 unordered_set(unordered_set const&, allocator_type const&);
|
Chris@16
|
116
|
Chris@16
|
117 #if defined(BOOST_UNORDERED_USE_MOVE)
|
Chris@16
|
118 unordered_set(BOOST_RV_REF(unordered_set) other)
|
Chris@16
|
119 BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
Chris@16
|
120 : table_(other.table_, boost::unordered::detail::move_tag())
|
Chris@16
|
121 {
|
Chris@16
|
122 }
|
Chris@16
|
123 #elif !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
Chris@16
|
124 unordered_set(unordered_set&& other)
|
Chris@16
|
125 BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
Chris@16
|
126 : table_(other.table_, boost::unordered::detail::move_tag())
|
Chris@16
|
127 {
|
Chris@16
|
128 }
|
Chris@16
|
129 #endif
|
Chris@16
|
130
|
Chris@16
|
131 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
Chris@16
|
132 unordered_set(unordered_set&&, allocator_type const&);
|
Chris@16
|
133 #endif
|
Chris@16
|
134
|
Chris@16
|
135 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
Chris@16
|
136 unordered_set(
|
Chris@16
|
137 std::initializer_list<value_type>,
|
Chris@16
|
138 size_type = boost::unordered::detail::default_bucket_count,
|
Chris@16
|
139 const hasher& = hasher(),
|
Chris@16
|
140 const key_equal&l = key_equal(),
|
Chris@16
|
141 const allocator_type& = allocator_type());
|
Chris@16
|
142 #endif
|
Chris@16
|
143
|
Chris@16
|
144 // Destructor
|
Chris@16
|
145
|
Chris@16
|
146 ~unordered_set() BOOST_NOEXCEPT;
|
Chris@16
|
147
|
Chris@16
|
148 // Assign
|
Chris@16
|
149
|
Chris@16
|
150 #if defined(BOOST_UNORDERED_USE_MOVE)
|
Chris@16
|
151 unordered_set& operator=(BOOST_COPY_ASSIGN_REF(unordered_set) x)
|
Chris@16
|
152 {
|
Chris@16
|
153 table_.assign(x.table_);
|
Chris@16
|
154 return *this;
|
Chris@16
|
155 }
|
Chris@16
|
156
|
Chris@16
|
157 unordered_set& operator=(BOOST_RV_REF(unordered_set) x)
|
Chris@16
|
158 {
|
Chris@16
|
159 table_.move_assign(x.table_);
|
Chris@16
|
160 return *this;
|
Chris@16
|
161 }
|
Chris@16
|
162 #else
|
Chris@16
|
163 unordered_set& operator=(unordered_set const& x)
|
Chris@16
|
164 {
|
Chris@16
|
165 table_.assign(x.table_);
|
Chris@16
|
166 return *this;
|
Chris@16
|
167 }
|
Chris@16
|
168
|
Chris@16
|
169 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
Chris@16
|
170 unordered_set& operator=(unordered_set&& x)
|
Chris@16
|
171 {
|
Chris@16
|
172 table_.move_assign(x.table_);
|
Chris@16
|
173 return *this;
|
Chris@16
|
174 }
|
Chris@16
|
175 #endif
|
Chris@16
|
176 #endif
|
Chris@16
|
177
|
Chris@16
|
178 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
Chris@16
|
179 unordered_set& operator=(std::initializer_list<value_type>);
|
Chris@16
|
180 #endif
|
Chris@16
|
181
|
Chris@16
|
182 allocator_type get_allocator() const BOOST_NOEXCEPT
|
Chris@16
|
183 {
|
Chris@16
|
184 return table_.node_alloc();
|
Chris@16
|
185 }
|
Chris@16
|
186
|
Chris@16
|
187 // size and capacity
|
Chris@16
|
188
|
Chris@16
|
189 bool empty() const BOOST_NOEXCEPT
|
Chris@16
|
190 {
|
Chris@16
|
191 return table_.size_ == 0;
|
Chris@16
|
192 }
|
Chris@16
|
193
|
Chris@16
|
194 size_type size() const BOOST_NOEXCEPT
|
Chris@16
|
195 {
|
Chris@16
|
196 return table_.size_;
|
Chris@16
|
197 }
|
Chris@16
|
198
|
Chris@16
|
199 size_type max_size() const BOOST_NOEXCEPT;
|
Chris@16
|
200
|
Chris@16
|
201 // iterators
|
Chris@16
|
202
|
Chris@16
|
203 iterator begin() BOOST_NOEXCEPT
|
Chris@16
|
204 {
|
Chris@16
|
205 return table_.begin();
|
Chris@16
|
206 }
|
Chris@16
|
207
|
Chris@16
|
208 const_iterator begin() const BOOST_NOEXCEPT
|
Chris@16
|
209 {
|
Chris@16
|
210 return table_.begin();
|
Chris@16
|
211 }
|
Chris@16
|
212
|
Chris@16
|
213 iterator end() BOOST_NOEXCEPT
|
Chris@16
|
214 {
|
Chris@16
|
215 return iterator();
|
Chris@16
|
216 }
|
Chris@16
|
217
|
Chris@16
|
218 const_iterator end() const BOOST_NOEXCEPT
|
Chris@16
|
219 {
|
Chris@16
|
220 return const_iterator();
|
Chris@16
|
221 }
|
Chris@16
|
222
|
Chris@16
|
223 const_iterator cbegin() const BOOST_NOEXCEPT
|
Chris@16
|
224 {
|
Chris@16
|
225 return table_.begin();
|
Chris@16
|
226 }
|
Chris@16
|
227
|
Chris@16
|
228 const_iterator cend() const BOOST_NOEXCEPT
|
Chris@16
|
229 {
|
Chris@16
|
230 return const_iterator();
|
Chris@16
|
231 }
|
Chris@16
|
232
|
Chris@16
|
233 // emplace
|
Chris@16
|
234
|
Chris@16
|
235 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@16
|
236 template <class... Args>
|
Chris@16
|
237 std::pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args)
|
Chris@16
|
238 {
|
Chris@16
|
239 return table_.emplace(boost::forward<Args>(args)...);
|
Chris@16
|
240 }
|
Chris@16
|
241
|
Chris@16
|
242 template <class... Args>
|
Chris@16
|
243 iterator emplace_hint(const_iterator, BOOST_FWD_REF(Args)... args)
|
Chris@16
|
244 {
|
Chris@16
|
245 return table_.emplace(boost::forward<Args>(args)...).first;
|
Chris@16
|
246 }
|
Chris@16
|
247 #else
|
Chris@16
|
248
|
Chris@16
|
249 #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
|
Chris@16
|
250
|
Chris@16
|
251 // 0 argument emplace requires special treatment in case
|
Chris@16
|
252 // the container is instantiated with a value type that
|
Chris@16
|
253 // doesn't have a default constructor.
|
Chris@16
|
254
|
Chris@16
|
255 std::pair<iterator, bool> emplace(
|
Chris@16
|
256 boost::unordered::detail::empty_emplace
|
Chris@16
|
257 = boost::unordered::detail::empty_emplace(),
|
Chris@16
|
258 value_type v = value_type())
|
Chris@16
|
259 {
|
Chris@16
|
260 return this->emplace(boost::move(v));
|
Chris@16
|
261 }
|
Chris@16
|
262
|
Chris@16
|
263 iterator emplace_hint(const_iterator hint,
|
Chris@16
|
264 boost::unordered::detail::empty_emplace
|
Chris@16
|
265 = boost::unordered::detail::empty_emplace(),
|
Chris@16
|
266 value_type v = value_type()
|
Chris@16
|
267 )
|
Chris@16
|
268 {
|
Chris@16
|
269 return this->emplace_hint(hint, boost::move(v));
|
Chris@16
|
270 }
|
Chris@16
|
271
|
Chris@16
|
272 #endif
|
Chris@16
|
273
|
Chris@16
|
274 template <typename A0>
|
Chris@16
|
275 std::pair<iterator, bool> emplace(BOOST_FWD_REF(A0) a0)
|
Chris@16
|
276 {
|
Chris@16
|
277 return table_.emplace(
|
Chris@16
|
278 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
279 boost::forward<A0>(a0))
|
Chris@16
|
280 );
|
Chris@16
|
281 }
|
Chris@16
|
282
|
Chris@16
|
283 template <typename A0>
|
Chris@16
|
284 iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0)
|
Chris@16
|
285 {
|
Chris@16
|
286 return table_.emplace(
|
Chris@16
|
287 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
288 boost::forward<A0>(a0))
|
Chris@16
|
289 ).first;
|
Chris@16
|
290 }
|
Chris@16
|
291
|
Chris@16
|
292 template <typename A0, typename A1>
|
Chris@16
|
293 std::pair<iterator, bool> emplace(
|
Chris@16
|
294 BOOST_FWD_REF(A0) a0,
|
Chris@16
|
295 BOOST_FWD_REF(A1) a1)
|
Chris@16
|
296 {
|
Chris@16
|
297 return table_.emplace(
|
Chris@16
|
298 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
299 boost::forward<A0>(a0),
|
Chris@16
|
300 boost::forward<A1>(a1))
|
Chris@16
|
301 );
|
Chris@16
|
302 }
|
Chris@16
|
303
|
Chris@16
|
304 template <typename A0, typename A1>
|
Chris@16
|
305 iterator emplace_hint(const_iterator,
|
Chris@16
|
306 BOOST_FWD_REF(A0) a0,
|
Chris@16
|
307 BOOST_FWD_REF(A1) a1)
|
Chris@16
|
308 {
|
Chris@16
|
309 return table_.emplace(
|
Chris@16
|
310 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
311 boost::forward<A0>(a0),
|
Chris@16
|
312 boost::forward<A1>(a1))
|
Chris@16
|
313 ).first;
|
Chris@16
|
314 }
|
Chris@16
|
315
|
Chris@16
|
316 template <typename A0, typename A1, typename A2>
|
Chris@16
|
317 std::pair<iterator, bool> emplace(
|
Chris@16
|
318 BOOST_FWD_REF(A0) a0,
|
Chris@16
|
319 BOOST_FWD_REF(A1) a1,
|
Chris@16
|
320 BOOST_FWD_REF(A2) a2)
|
Chris@16
|
321 {
|
Chris@16
|
322 return table_.emplace(
|
Chris@16
|
323 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
324 boost::forward<A0>(a0),
|
Chris@16
|
325 boost::forward<A1>(a1),
|
Chris@16
|
326 boost::forward<A2>(a2))
|
Chris@16
|
327 );
|
Chris@16
|
328 }
|
Chris@16
|
329
|
Chris@16
|
330 template <typename A0, typename A1, typename A2>
|
Chris@16
|
331 iterator emplace_hint(const_iterator,
|
Chris@16
|
332 BOOST_FWD_REF(A0) a0,
|
Chris@16
|
333 BOOST_FWD_REF(A1) a1,
|
Chris@16
|
334 BOOST_FWD_REF(A2) a2)
|
Chris@16
|
335 {
|
Chris@16
|
336 return table_.emplace(
|
Chris@16
|
337 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
338 boost::forward<A0>(a0),
|
Chris@16
|
339 boost::forward<A1>(a1),
|
Chris@16
|
340 boost::forward<A2>(a2))
|
Chris@16
|
341 ).first;
|
Chris@16
|
342 }
|
Chris@16
|
343
|
Chris@16
|
344 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
|
Chris@16
|
345 template < \
|
Chris@16
|
346 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
|
Chris@16
|
347 > \
|
Chris@16
|
348 std::pair<iterator, bool> emplace( \
|
Chris@16
|
349 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
|
Chris@16
|
350 ) \
|
Chris@16
|
351 { \
|
Chris@16
|
352 return table_.emplace( \
|
Chris@16
|
353 boost::unordered::detail::create_emplace_args( \
|
Chris@16
|
354 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
|
Chris@16
|
355 a) \
|
Chris@16
|
356 )); \
|
Chris@16
|
357 } \
|
Chris@16
|
358 \
|
Chris@16
|
359 template < \
|
Chris@16
|
360 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
|
Chris@16
|
361 > \
|
Chris@16
|
362 iterator emplace_hint( \
|
Chris@16
|
363 const_iterator, \
|
Chris@16
|
364 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
|
Chris@16
|
365 ) \
|
Chris@16
|
366 { \
|
Chris@16
|
367 return table_.emplace( \
|
Chris@16
|
368 boost::unordered::detail::create_emplace_args( \
|
Chris@16
|
369 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
|
Chris@16
|
370 a) \
|
Chris@16
|
371 )).first; \
|
Chris@16
|
372 }
|
Chris@16
|
373
|
Chris@16
|
374 BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
|
Chris@16
|
375 BOOST_UNORDERED_EMPLACE, _)
|
Chris@16
|
376
|
Chris@16
|
377 #undef BOOST_UNORDERED_EMPLACE
|
Chris@16
|
378
|
Chris@16
|
379 #endif
|
Chris@16
|
380
|
Chris@16
|
381 std::pair<iterator, bool> insert(value_type const& x)
|
Chris@16
|
382 {
|
Chris@16
|
383 return this->emplace(x);
|
Chris@16
|
384 }
|
Chris@16
|
385
|
Chris@16
|
386 std::pair<iterator, bool> insert(BOOST_UNORDERED_RV_REF(value_type) x)
|
Chris@16
|
387 {
|
Chris@16
|
388 return this->emplace(boost::move(x));
|
Chris@16
|
389 }
|
Chris@16
|
390
|
Chris@16
|
391 iterator insert(const_iterator hint, value_type const& x)
|
Chris@16
|
392 {
|
Chris@16
|
393 return this->emplace_hint(hint, x);
|
Chris@16
|
394 }
|
Chris@16
|
395
|
Chris@16
|
396 iterator insert(const_iterator hint,
|
Chris@16
|
397 BOOST_UNORDERED_RV_REF(value_type) x)
|
Chris@16
|
398 {
|
Chris@16
|
399 return this->emplace_hint(hint, boost::move(x));
|
Chris@16
|
400 }
|
Chris@16
|
401
|
Chris@16
|
402 template <class InputIt> void insert(InputIt, InputIt);
|
Chris@16
|
403
|
Chris@16
|
404 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
Chris@16
|
405 void insert(std::initializer_list<value_type>);
|
Chris@16
|
406 #endif
|
Chris@16
|
407
|
Chris@16
|
408 iterator erase(const_iterator);
|
Chris@16
|
409 size_type erase(const key_type&);
|
Chris@16
|
410 iterator erase(const_iterator, const_iterator);
|
Chris@16
|
411 void quick_erase(const_iterator it) { erase(it); }
|
Chris@16
|
412 void erase_return_void(const_iterator it) { erase(it); }
|
Chris@16
|
413
|
Chris@16
|
414 void clear();
|
Chris@16
|
415 void swap(unordered_set&);
|
Chris@16
|
416
|
Chris@16
|
417 // observers
|
Chris@16
|
418
|
Chris@16
|
419 hasher hash_function() const;
|
Chris@16
|
420 key_equal key_eq() const;
|
Chris@16
|
421
|
Chris@16
|
422 // lookup
|
Chris@16
|
423
|
Chris@16
|
424 const_iterator find(const key_type&) const;
|
Chris@16
|
425
|
Chris@16
|
426 template <class CompatibleKey, class CompatibleHash,
|
Chris@16
|
427 class CompatiblePredicate>
|
Chris@16
|
428 const_iterator find(
|
Chris@16
|
429 CompatibleKey const&,
|
Chris@16
|
430 CompatibleHash const&,
|
Chris@16
|
431 CompatiblePredicate const&) const;
|
Chris@16
|
432
|
Chris@16
|
433 size_type count(const key_type&) const;
|
Chris@16
|
434
|
Chris@16
|
435 std::pair<const_iterator, const_iterator>
|
Chris@16
|
436 equal_range(const key_type&) const;
|
Chris@16
|
437
|
Chris@16
|
438 // bucket interface
|
Chris@16
|
439
|
Chris@16
|
440 size_type bucket_count() const BOOST_NOEXCEPT
|
Chris@16
|
441 {
|
Chris@16
|
442 return table_.bucket_count_;
|
Chris@16
|
443 }
|
Chris@16
|
444
|
Chris@16
|
445 size_type max_bucket_count() const BOOST_NOEXCEPT
|
Chris@16
|
446 {
|
Chris@16
|
447 return table_.max_bucket_count();
|
Chris@16
|
448 }
|
Chris@16
|
449
|
Chris@16
|
450 size_type bucket_size(size_type) const;
|
Chris@16
|
451
|
Chris@16
|
452 size_type bucket(const key_type& k) const
|
Chris@16
|
453 {
|
Chris@16
|
454 return table_.hash_to_bucket(table_.hash(k));
|
Chris@16
|
455 }
|
Chris@16
|
456
|
Chris@16
|
457 local_iterator begin(size_type n)
|
Chris@16
|
458 {
|
Chris@16
|
459 return local_iterator(
|
Chris@16
|
460 table_.begin(n), n, table_.bucket_count_);
|
Chris@16
|
461 }
|
Chris@16
|
462
|
Chris@16
|
463 const_local_iterator begin(size_type n) const
|
Chris@16
|
464 {
|
Chris@16
|
465 return const_local_iterator(
|
Chris@16
|
466 table_.begin(n), n, table_.bucket_count_);
|
Chris@16
|
467 }
|
Chris@16
|
468
|
Chris@16
|
469 local_iterator end(size_type)
|
Chris@16
|
470 {
|
Chris@16
|
471 return local_iterator();
|
Chris@16
|
472 }
|
Chris@16
|
473
|
Chris@16
|
474 const_local_iterator end(size_type) const
|
Chris@16
|
475 {
|
Chris@16
|
476 return const_local_iterator();
|
Chris@16
|
477 }
|
Chris@16
|
478
|
Chris@16
|
479 const_local_iterator cbegin(size_type n) const
|
Chris@16
|
480 {
|
Chris@16
|
481 return const_local_iterator(
|
Chris@16
|
482 table_.begin(n), n, table_.bucket_count_);
|
Chris@16
|
483 }
|
Chris@16
|
484
|
Chris@16
|
485 const_local_iterator cend(size_type) const
|
Chris@16
|
486 {
|
Chris@16
|
487 return const_local_iterator();
|
Chris@16
|
488 }
|
Chris@16
|
489
|
Chris@16
|
490 // hash policy
|
Chris@16
|
491
|
Chris@16
|
492 float max_load_factor() const BOOST_NOEXCEPT
|
Chris@16
|
493 {
|
Chris@16
|
494 return table_.mlf_;
|
Chris@16
|
495 }
|
Chris@16
|
496
|
Chris@16
|
497 float load_factor() const BOOST_NOEXCEPT;
|
Chris@16
|
498 void max_load_factor(float) BOOST_NOEXCEPT;
|
Chris@16
|
499 void rehash(size_type);
|
Chris@16
|
500 void reserve(size_type);
|
Chris@16
|
501
|
Chris@16
|
502 #if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
|
Chris@16
|
503 friend bool operator==<T,H,P,A>(
|
Chris@16
|
504 unordered_set const&, unordered_set const&);
|
Chris@16
|
505 friend bool operator!=<T,H,P,A>(
|
Chris@16
|
506 unordered_set const&, unordered_set const&);
|
Chris@16
|
507 #endif
|
Chris@16
|
508 }; // class template unordered_set
|
Chris@16
|
509
|
Chris@16
|
510 template <class T, class H, class P, class A>
|
Chris@16
|
511 class unordered_multiset
|
Chris@16
|
512 {
|
Chris@16
|
513 #if defined(BOOST_UNORDERED_USE_MOVE)
|
Chris@16
|
514 BOOST_COPYABLE_AND_MOVABLE(unordered_multiset)
|
Chris@16
|
515 #endif
|
Chris@16
|
516 public:
|
Chris@16
|
517
|
Chris@16
|
518 typedef T key_type;
|
Chris@16
|
519 typedef T value_type;
|
Chris@16
|
520 typedef H hasher;
|
Chris@16
|
521 typedef P key_equal;
|
Chris@16
|
522 typedef A allocator_type;
|
Chris@16
|
523
|
Chris@16
|
524 private:
|
Chris@16
|
525
|
Chris@16
|
526 typedef boost::unordered::detail::multiset<A, T, H, P> types;
|
Chris@16
|
527 typedef typename types::traits allocator_traits;
|
Chris@16
|
528 typedef typename types::table table;
|
Chris@16
|
529
|
Chris@16
|
530 public:
|
Chris@16
|
531
|
Chris@16
|
532 typedef typename allocator_traits::pointer pointer;
|
Chris@16
|
533 typedef typename allocator_traits::const_pointer const_pointer;
|
Chris@16
|
534
|
Chris@16
|
535 typedef value_type& reference;
|
Chris@16
|
536 typedef value_type const& const_reference;
|
Chris@16
|
537
|
Chris@16
|
538 typedef std::size_t size_type;
|
Chris@16
|
539 typedef std::ptrdiff_t difference_type;
|
Chris@16
|
540
|
Chris@16
|
541 typedef typename table::cl_iterator const_local_iterator;
|
Chris@16
|
542 typedef typename table::cl_iterator local_iterator;
|
Chris@16
|
543 typedef typename table::c_iterator const_iterator;
|
Chris@16
|
544 typedef typename table::c_iterator iterator;
|
Chris@16
|
545
|
Chris@16
|
546 private:
|
Chris@16
|
547
|
Chris@16
|
548 table table_;
|
Chris@16
|
549
|
Chris@16
|
550 public:
|
Chris@16
|
551
|
Chris@16
|
552 // constructors
|
Chris@16
|
553
|
Chris@16
|
554 explicit unordered_multiset(
|
Chris@16
|
555 size_type = boost::unordered::detail::default_bucket_count,
|
Chris@16
|
556 const hasher& = hasher(),
|
Chris@16
|
557 const key_equal& = key_equal(),
|
Chris@16
|
558 const allocator_type& = allocator_type());
|
Chris@16
|
559
|
Chris@16
|
560 explicit unordered_multiset(allocator_type const&);
|
Chris@16
|
561
|
Chris@16
|
562 template <class InputIt>
|
Chris@16
|
563 unordered_multiset(InputIt, InputIt);
|
Chris@16
|
564
|
Chris@16
|
565 template <class InputIt>
|
Chris@16
|
566 unordered_multiset(
|
Chris@16
|
567 InputIt, InputIt,
|
Chris@16
|
568 size_type,
|
Chris@16
|
569 const hasher& = hasher(),
|
Chris@16
|
570 const key_equal& = key_equal());
|
Chris@16
|
571
|
Chris@16
|
572 template <class InputIt>
|
Chris@16
|
573 unordered_multiset(
|
Chris@16
|
574 InputIt, InputIt,
|
Chris@16
|
575 size_type,
|
Chris@16
|
576 const hasher&,
|
Chris@16
|
577 const key_equal&,
|
Chris@16
|
578 const allocator_type&);
|
Chris@16
|
579
|
Chris@16
|
580 // copy/move constructors
|
Chris@16
|
581
|
Chris@16
|
582 unordered_multiset(unordered_multiset const&);
|
Chris@16
|
583
|
Chris@16
|
584 unordered_multiset(unordered_multiset const&, allocator_type const&);
|
Chris@16
|
585
|
Chris@16
|
586 #if defined(BOOST_UNORDERED_USE_MOVE)
|
Chris@16
|
587 unordered_multiset(BOOST_RV_REF(unordered_multiset) other)
|
Chris@16
|
588 BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
Chris@16
|
589 : table_(other.table_, boost::unordered::detail::move_tag())
|
Chris@16
|
590 {
|
Chris@16
|
591 }
|
Chris@16
|
592 #elif !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
Chris@16
|
593 unordered_multiset(unordered_multiset&& other)
|
Chris@16
|
594 BOOST_NOEXCEPT_IF(table::nothrow_move_constructible)
|
Chris@16
|
595 : table_(other.table_, boost::unordered::detail::move_tag())
|
Chris@16
|
596 {
|
Chris@16
|
597 }
|
Chris@16
|
598 #endif
|
Chris@16
|
599
|
Chris@16
|
600 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
Chris@16
|
601 unordered_multiset(unordered_multiset&&, allocator_type const&);
|
Chris@16
|
602 #endif
|
Chris@16
|
603
|
Chris@16
|
604 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
Chris@16
|
605 unordered_multiset(
|
Chris@16
|
606 std::initializer_list<value_type>,
|
Chris@16
|
607 size_type = boost::unordered::detail::default_bucket_count,
|
Chris@16
|
608 const hasher& = hasher(),
|
Chris@16
|
609 const key_equal&l = key_equal(),
|
Chris@16
|
610 const allocator_type& = allocator_type());
|
Chris@16
|
611 #endif
|
Chris@16
|
612
|
Chris@16
|
613 // Destructor
|
Chris@16
|
614
|
Chris@16
|
615 ~unordered_multiset() BOOST_NOEXCEPT;
|
Chris@16
|
616
|
Chris@16
|
617 // Assign
|
Chris@16
|
618
|
Chris@16
|
619 #if defined(BOOST_UNORDERED_USE_MOVE)
|
Chris@16
|
620 unordered_multiset& operator=(
|
Chris@16
|
621 BOOST_COPY_ASSIGN_REF(unordered_multiset) x)
|
Chris@16
|
622 {
|
Chris@16
|
623 table_.assign(x.table_);
|
Chris@16
|
624 return *this;
|
Chris@16
|
625 }
|
Chris@16
|
626
|
Chris@16
|
627 unordered_multiset& operator=(BOOST_RV_REF(unordered_multiset) x)
|
Chris@16
|
628 {
|
Chris@16
|
629 table_.move_assign(x.table_);
|
Chris@16
|
630 return *this;
|
Chris@16
|
631 }
|
Chris@16
|
632 #else
|
Chris@16
|
633 unordered_multiset& operator=(unordered_multiset const& x)
|
Chris@16
|
634 {
|
Chris@16
|
635 table_.assign(x.table_);
|
Chris@16
|
636 return *this;
|
Chris@16
|
637 }
|
Chris@16
|
638
|
Chris@16
|
639 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
Chris@16
|
640 unordered_multiset& operator=(unordered_multiset&& x)
|
Chris@16
|
641 {
|
Chris@16
|
642 table_.move_assign(x.table_);
|
Chris@16
|
643 return *this;
|
Chris@16
|
644 }
|
Chris@16
|
645 #endif
|
Chris@16
|
646 #endif
|
Chris@16
|
647
|
Chris@16
|
648 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
Chris@16
|
649 unordered_multiset& operator=(std::initializer_list<value_type>);
|
Chris@16
|
650 #endif
|
Chris@16
|
651
|
Chris@16
|
652 allocator_type get_allocator() const BOOST_NOEXCEPT
|
Chris@16
|
653 {
|
Chris@16
|
654 return table_.node_alloc();
|
Chris@16
|
655 }
|
Chris@16
|
656
|
Chris@16
|
657 // size and capacity
|
Chris@16
|
658
|
Chris@16
|
659 bool empty() const BOOST_NOEXCEPT
|
Chris@16
|
660 {
|
Chris@16
|
661 return table_.size_ == 0;
|
Chris@16
|
662 }
|
Chris@16
|
663
|
Chris@16
|
664 size_type size() const BOOST_NOEXCEPT
|
Chris@16
|
665 {
|
Chris@16
|
666 return table_.size_;
|
Chris@16
|
667 }
|
Chris@16
|
668
|
Chris@16
|
669 size_type max_size() const BOOST_NOEXCEPT;
|
Chris@16
|
670
|
Chris@16
|
671 // iterators
|
Chris@16
|
672
|
Chris@16
|
673 iterator begin() BOOST_NOEXCEPT
|
Chris@16
|
674 {
|
Chris@16
|
675 return iterator(table_.begin());
|
Chris@16
|
676 }
|
Chris@16
|
677
|
Chris@16
|
678 const_iterator begin() const BOOST_NOEXCEPT
|
Chris@16
|
679 {
|
Chris@16
|
680 return const_iterator(table_.begin());
|
Chris@16
|
681 }
|
Chris@16
|
682
|
Chris@16
|
683 iterator end() BOOST_NOEXCEPT
|
Chris@16
|
684 {
|
Chris@16
|
685 return iterator();
|
Chris@16
|
686 }
|
Chris@16
|
687
|
Chris@16
|
688 const_iterator end() const BOOST_NOEXCEPT
|
Chris@16
|
689 {
|
Chris@16
|
690 return const_iterator();
|
Chris@16
|
691 }
|
Chris@16
|
692
|
Chris@16
|
693 const_iterator cbegin() const BOOST_NOEXCEPT
|
Chris@16
|
694 {
|
Chris@16
|
695 return const_iterator(table_.begin());
|
Chris@16
|
696 }
|
Chris@16
|
697
|
Chris@16
|
698 const_iterator cend() const BOOST_NOEXCEPT
|
Chris@16
|
699 {
|
Chris@16
|
700 return const_iterator();
|
Chris@16
|
701 }
|
Chris@16
|
702
|
Chris@16
|
703 // emplace
|
Chris@16
|
704
|
Chris@16
|
705 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@16
|
706 template <class... Args>
|
Chris@16
|
707 iterator emplace(BOOST_FWD_REF(Args)... args)
|
Chris@16
|
708 {
|
Chris@16
|
709 return table_.emplace(boost::forward<Args>(args)...);
|
Chris@16
|
710 }
|
Chris@16
|
711
|
Chris@16
|
712 template <class... Args>
|
Chris@16
|
713 iterator emplace_hint(const_iterator, BOOST_FWD_REF(Args)... args)
|
Chris@16
|
714 {
|
Chris@16
|
715 return table_.emplace(boost::forward<Args>(args)...);
|
Chris@16
|
716 }
|
Chris@16
|
717 #else
|
Chris@16
|
718
|
Chris@16
|
719 #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
|
Chris@16
|
720
|
Chris@16
|
721 // 0 argument emplace requires special treatment in case
|
Chris@16
|
722 // the container is instantiated with a value type that
|
Chris@16
|
723 // doesn't have a default constructor.
|
Chris@16
|
724
|
Chris@16
|
725 iterator emplace(
|
Chris@16
|
726 boost::unordered::detail::empty_emplace
|
Chris@16
|
727 = boost::unordered::detail::empty_emplace(),
|
Chris@16
|
728 value_type v = value_type())
|
Chris@16
|
729 {
|
Chris@16
|
730 return this->emplace(boost::move(v));
|
Chris@16
|
731 }
|
Chris@16
|
732
|
Chris@16
|
733 iterator emplace_hint(const_iterator hint,
|
Chris@16
|
734 boost::unordered::detail::empty_emplace
|
Chris@16
|
735 = boost::unordered::detail::empty_emplace(),
|
Chris@16
|
736 value_type v = value_type()
|
Chris@16
|
737 )
|
Chris@16
|
738 {
|
Chris@16
|
739 return this->emplace_hint(hint, boost::move(v));
|
Chris@16
|
740 }
|
Chris@16
|
741
|
Chris@16
|
742 #endif
|
Chris@16
|
743
|
Chris@16
|
744 template <typename A0>
|
Chris@16
|
745 iterator emplace(BOOST_FWD_REF(A0) a0)
|
Chris@16
|
746 {
|
Chris@16
|
747 return table_.emplace(
|
Chris@16
|
748 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
749 boost::forward<A0>(a0))
|
Chris@16
|
750 );
|
Chris@16
|
751 }
|
Chris@16
|
752
|
Chris@16
|
753 template <typename A0>
|
Chris@16
|
754 iterator emplace_hint(const_iterator, BOOST_FWD_REF(A0) a0)
|
Chris@16
|
755 {
|
Chris@16
|
756 return table_.emplace(
|
Chris@16
|
757 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
758 boost::forward<A0>(a0))
|
Chris@16
|
759 );
|
Chris@16
|
760 }
|
Chris@16
|
761
|
Chris@16
|
762 template <typename A0, typename A1>
|
Chris@16
|
763 iterator emplace(
|
Chris@16
|
764 BOOST_FWD_REF(A0) a0,
|
Chris@16
|
765 BOOST_FWD_REF(A1) a1)
|
Chris@16
|
766 {
|
Chris@16
|
767 return table_.emplace(
|
Chris@16
|
768 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
769 boost::forward<A0>(a0),
|
Chris@16
|
770 boost::forward<A1>(a1))
|
Chris@16
|
771 );
|
Chris@16
|
772 }
|
Chris@16
|
773
|
Chris@16
|
774 template <typename A0, typename A1>
|
Chris@16
|
775 iterator emplace_hint(const_iterator,
|
Chris@16
|
776 BOOST_FWD_REF(A0) a0,
|
Chris@16
|
777 BOOST_FWD_REF(A1) a1)
|
Chris@16
|
778 {
|
Chris@16
|
779 return table_.emplace(
|
Chris@16
|
780 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
781 boost::forward<A0>(a0),
|
Chris@16
|
782 boost::forward<A1>(a1))
|
Chris@16
|
783 );
|
Chris@16
|
784 }
|
Chris@16
|
785
|
Chris@16
|
786 template <typename A0, typename A1, typename A2>
|
Chris@16
|
787 iterator emplace(
|
Chris@16
|
788 BOOST_FWD_REF(A0) a0,
|
Chris@16
|
789 BOOST_FWD_REF(A1) a1,
|
Chris@16
|
790 BOOST_FWD_REF(A2) a2)
|
Chris@16
|
791 {
|
Chris@16
|
792 return table_.emplace(
|
Chris@16
|
793 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
794 boost::forward<A0>(a0),
|
Chris@16
|
795 boost::forward<A1>(a1),
|
Chris@16
|
796 boost::forward<A2>(a2))
|
Chris@16
|
797 );
|
Chris@16
|
798 }
|
Chris@16
|
799
|
Chris@16
|
800 template <typename A0, typename A1, typename A2>
|
Chris@16
|
801 iterator emplace_hint(const_iterator,
|
Chris@16
|
802 BOOST_FWD_REF(A0) a0,
|
Chris@16
|
803 BOOST_FWD_REF(A1) a1,
|
Chris@16
|
804 BOOST_FWD_REF(A2) a2)
|
Chris@16
|
805 {
|
Chris@16
|
806 return table_.emplace(
|
Chris@16
|
807 boost::unordered::detail::create_emplace_args(
|
Chris@16
|
808 boost::forward<A0>(a0),
|
Chris@16
|
809 boost::forward<A1>(a1),
|
Chris@16
|
810 boost::forward<A2>(a2))
|
Chris@16
|
811 );
|
Chris@16
|
812 }
|
Chris@16
|
813
|
Chris@16
|
814 #define BOOST_UNORDERED_EMPLACE(z, n, _) \
|
Chris@16
|
815 template < \
|
Chris@16
|
816 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
|
Chris@16
|
817 > \
|
Chris@16
|
818 iterator emplace( \
|
Chris@16
|
819 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
|
Chris@16
|
820 ) \
|
Chris@16
|
821 { \
|
Chris@16
|
822 return table_.emplace( \
|
Chris@16
|
823 boost::unordered::detail::create_emplace_args( \
|
Chris@16
|
824 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
|
Chris@16
|
825 a) \
|
Chris@16
|
826 )); \
|
Chris@16
|
827 } \
|
Chris@16
|
828 \
|
Chris@16
|
829 template < \
|
Chris@16
|
830 BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \
|
Chris@16
|
831 > \
|
Chris@16
|
832 iterator emplace_hint( \
|
Chris@16
|
833 const_iterator, \
|
Chris@16
|
834 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_FWD_PARAM, a) \
|
Chris@16
|
835 ) \
|
Chris@16
|
836 { \
|
Chris@16
|
837 return table_.emplace( \
|
Chris@16
|
838 boost::unordered::detail::create_emplace_args( \
|
Chris@16
|
839 BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_CALL_FORWARD, \
|
Chris@16
|
840 a) \
|
Chris@16
|
841 )); \
|
Chris@16
|
842 }
|
Chris@16
|
843
|
Chris@16
|
844 BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
|
Chris@16
|
845 BOOST_UNORDERED_EMPLACE, _)
|
Chris@16
|
846
|
Chris@16
|
847 #undef BOOST_UNORDERED_EMPLACE
|
Chris@16
|
848
|
Chris@16
|
849 #endif
|
Chris@16
|
850
|
Chris@16
|
851 iterator insert(value_type const& x)
|
Chris@16
|
852 {
|
Chris@16
|
853 return this->emplace(x);
|
Chris@16
|
854 }
|
Chris@16
|
855
|
Chris@16
|
856 iterator insert(BOOST_UNORDERED_RV_REF(value_type) x)
|
Chris@16
|
857 {
|
Chris@16
|
858 return this->emplace(boost::move(x));
|
Chris@16
|
859 }
|
Chris@16
|
860
|
Chris@16
|
861 iterator insert(const_iterator hint, value_type const& x)
|
Chris@16
|
862 {
|
Chris@16
|
863 return this->emplace_hint(hint, x);
|
Chris@16
|
864 }
|
Chris@16
|
865
|
Chris@16
|
866 iterator insert(const_iterator hint,
|
Chris@16
|
867 BOOST_UNORDERED_RV_REF(value_type) x)
|
Chris@16
|
868 {
|
Chris@16
|
869 return this->emplace_hint(hint, boost::move(x));
|
Chris@16
|
870 }
|
Chris@16
|
871
|
Chris@16
|
872 template <class InputIt> void insert(InputIt, InputIt);
|
Chris@16
|
873
|
Chris@16
|
874 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
Chris@16
|
875 void insert(std::initializer_list<value_type>);
|
Chris@16
|
876 #endif
|
Chris@16
|
877
|
Chris@16
|
878 iterator erase(const_iterator);
|
Chris@16
|
879 size_type erase(const key_type&);
|
Chris@16
|
880 iterator erase(const_iterator, const_iterator);
|
Chris@16
|
881 void quick_erase(const_iterator it) { erase(it); }
|
Chris@16
|
882 void erase_return_void(const_iterator it) { erase(it); }
|
Chris@16
|
883
|
Chris@16
|
884 void clear();
|
Chris@16
|
885 void swap(unordered_multiset&);
|
Chris@16
|
886
|
Chris@16
|
887 // observers
|
Chris@16
|
888
|
Chris@16
|
889 hasher hash_function() const;
|
Chris@16
|
890 key_equal key_eq() const;
|
Chris@16
|
891
|
Chris@16
|
892 // lookup
|
Chris@16
|
893
|
Chris@16
|
894 const_iterator find(const key_type&) const;
|
Chris@16
|
895
|
Chris@16
|
896 template <class CompatibleKey, class CompatibleHash,
|
Chris@16
|
897 class CompatiblePredicate>
|
Chris@16
|
898 const_iterator find(
|
Chris@16
|
899 CompatibleKey const&,
|
Chris@16
|
900 CompatibleHash const&,
|
Chris@16
|
901 CompatiblePredicate const&) const;
|
Chris@16
|
902
|
Chris@16
|
903 size_type count(const key_type&) const;
|
Chris@16
|
904
|
Chris@16
|
905 std::pair<const_iterator, const_iterator>
|
Chris@16
|
906 equal_range(const key_type&) const;
|
Chris@16
|
907
|
Chris@16
|
908 // bucket interface
|
Chris@16
|
909
|
Chris@16
|
910 size_type bucket_count() const BOOST_NOEXCEPT
|
Chris@16
|
911 {
|
Chris@16
|
912 return table_.bucket_count_;
|
Chris@16
|
913 }
|
Chris@16
|
914
|
Chris@16
|
915 size_type max_bucket_count() const BOOST_NOEXCEPT
|
Chris@16
|
916 {
|
Chris@16
|
917 return table_.max_bucket_count();
|
Chris@16
|
918 }
|
Chris@16
|
919
|
Chris@16
|
920 size_type bucket_size(size_type) const;
|
Chris@16
|
921
|
Chris@16
|
922 size_type bucket(const key_type& k) const
|
Chris@16
|
923 {
|
Chris@16
|
924 return table_.hash_to_bucket(table_.hash(k));
|
Chris@16
|
925 }
|
Chris@16
|
926
|
Chris@16
|
927 local_iterator begin(size_type n)
|
Chris@16
|
928 {
|
Chris@16
|
929 return local_iterator(
|
Chris@16
|
930 table_.begin(n), n, table_.bucket_count_);
|
Chris@16
|
931 }
|
Chris@16
|
932
|
Chris@16
|
933 const_local_iterator begin(size_type n) const
|
Chris@16
|
934 {
|
Chris@16
|
935 return const_local_iterator(
|
Chris@16
|
936 table_.begin(n), n, table_.bucket_count_);
|
Chris@16
|
937 }
|
Chris@16
|
938
|
Chris@16
|
939 local_iterator end(size_type)
|
Chris@16
|
940 {
|
Chris@16
|
941 return local_iterator();
|
Chris@16
|
942 }
|
Chris@16
|
943
|
Chris@16
|
944 const_local_iterator end(size_type) const
|
Chris@16
|
945 {
|
Chris@16
|
946 return const_local_iterator();
|
Chris@16
|
947 }
|
Chris@16
|
948
|
Chris@16
|
949 const_local_iterator cbegin(size_type n) const
|
Chris@16
|
950 {
|
Chris@16
|
951 return const_local_iterator(
|
Chris@16
|
952 table_.begin(n), n, table_.bucket_count_);
|
Chris@16
|
953 }
|
Chris@16
|
954
|
Chris@16
|
955 const_local_iterator cend(size_type) const
|
Chris@16
|
956 {
|
Chris@16
|
957 return const_local_iterator();
|
Chris@16
|
958 }
|
Chris@16
|
959
|
Chris@16
|
960 // hash policy
|
Chris@16
|
961
|
Chris@16
|
962 float max_load_factor() const BOOST_NOEXCEPT
|
Chris@16
|
963 {
|
Chris@16
|
964 return table_.mlf_;
|
Chris@16
|
965 }
|
Chris@16
|
966
|
Chris@16
|
967 float load_factor() const BOOST_NOEXCEPT;
|
Chris@16
|
968 void max_load_factor(float) BOOST_NOEXCEPT;
|
Chris@16
|
969 void rehash(size_type);
|
Chris@16
|
970 void reserve(size_type);
|
Chris@16
|
971
|
Chris@16
|
972 #if !BOOST_WORKAROUND(__BORLANDC__, < 0x0582)
|
Chris@16
|
973 friend bool operator==<T,H,P,A>(
|
Chris@16
|
974 unordered_multiset const&, unordered_multiset const&);
|
Chris@16
|
975 friend bool operator!=<T,H,P,A>(
|
Chris@16
|
976 unordered_multiset const&, unordered_multiset const&);
|
Chris@16
|
977 #endif
|
Chris@16
|
978 }; // class template unordered_multiset
|
Chris@16
|
979
|
Chris@16
|
980 ////////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
981
|
Chris@16
|
982 template <class T, class H, class P, class A>
|
Chris@16
|
983 unordered_set<T,H,P,A>::unordered_set(
|
Chris@16
|
984 size_type n, const hasher &hf, const key_equal &eql,
|
Chris@16
|
985 const allocator_type &a)
|
Chris@16
|
986 : table_(n, hf, eql, a)
|
Chris@16
|
987 {
|
Chris@16
|
988 }
|
Chris@16
|
989
|
Chris@16
|
990 template <class T, class H, class P, class A>
|
Chris@16
|
991 unordered_set<T,H,P,A>::unordered_set(allocator_type const& a)
|
Chris@16
|
992 : table_(boost::unordered::detail::default_bucket_count,
|
Chris@16
|
993 hasher(), key_equal(), a)
|
Chris@16
|
994 {
|
Chris@16
|
995 }
|
Chris@16
|
996
|
Chris@16
|
997 template <class T, class H, class P, class A>
|
Chris@16
|
998 unordered_set<T,H,P,A>::unordered_set(
|
Chris@16
|
999 unordered_set const& other, allocator_type const& a)
|
Chris@16
|
1000 : table_(other.table_, a)
|
Chris@16
|
1001 {
|
Chris@16
|
1002 }
|
Chris@16
|
1003
|
Chris@16
|
1004 template <class T, class H, class P, class A>
|
Chris@16
|
1005 template <class InputIt>
|
Chris@16
|
1006 unordered_set<T,H,P,A>::unordered_set(InputIt f, InputIt l)
|
Chris@16
|
1007 : table_(boost::unordered::detail::initial_size(f, l),
|
Chris@16
|
1008 hasher(), key_equal(), allocator_type())
|
Chris@16
|
1009 {
|
Chris@16
|
1010 table_.insert_range(f, l);
|
Chris@16
|
1011 }
|
Chris@16
|
1012
|
Chris@16
|
1013 template <class T, class H, class P, class A>
|
Chris@16
|
1014 template <class InputIt>
|
Chris@16
|
1015 unordered_set<T,H,P,A>::unordered_set(
|
Chris@16
|
1016 InputIt f, InputIt l,
|
Chris@16
|
1017 size_type n,
|
Chris@16
|
1018 const hasher &hf,
|
Chris@16
|
1019 const key_equal &eql)
|
Chris@16
|
1020 : table_(boost::unordered::detail::initial_size(f, l, n),
|
Chris@16
|
1021 hf, eql, allocator_type())
|
Chris@16
|
1022 {
|
Chris@16
|
1023 table_.insert_range(f, l);
|
Chris@16
|
1024 }
|
Chris@16
|
1025
|
Chris@16
|
1026 template <class T, class H, class P, class A>
|
Chris@16
|
1027 template <class InputIt>
|
Chris@16
|
1028 unordered_set<T,H,P,A>::unordered_set(
|
Chris@16
|
1029 InputIt f, InputIt l,
|
Chris@16
|
1030 size_type n,
|
Chris@16
|
1031 const hasher &hf,
|
Chris@16
|
1032 const key_equal &eql,
|
Chris@16
|
1033 const allocator_type &a)
|
Chris@16
|
1034 : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a)
|
Chris@16
|
1035 {
|
Chris@16
|
1036 table_.insert_range(f, l);
|
Chris@16
|
1037 }
|
Chris@16
|
1038
|
Chris@16
|
1039 template <class T, class H, class P, class A>
|
Chris@16
|
1040 unordered_set<T,H,P,A>::~unordered_set() BOOST_NOEXCEPT {}
|
Chris@16
|
1041
|
Chris@16
|
1042 template <class T, class H, class P, class A>
|
Chris@16
|
1043 unordered_set<T,H,P,A>::unordered_set(
|
Chris@16
|
1044 unordered_set const& other)
|
Chris@16
|
1045 : table_(other.table_)
|
Chris@16
|
1046 {
|
Chris@16
|
1047 }
|
Chris@16
|
1048
|
Chris@16
|
1049 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
Chris@16
|
1050
|
Chris@16
|
1051 template <class T, class H, class P, class A>
|
Chris@16
|
1052 unordered_set<T,H,P,A>::unordered_set(
|
Chris@16
|
1053 unordered_set&& other, allocator_type const& a)
|
Chris@16
|
1054 : table_(other.table_, a, boost::unordered::detail::move_tag())
|
Chris@16
|
1055 {
|
Chris@16
|
1056 }
|
Chris@16
|
1057
|
Chris@16
|
1058 #endif
|
Chris@16
|
1059
|
Chris@16
|
1060 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
Chris@16
|
1061
|
Chris@16
|
1062 template <class T, class H, class P, class A>
|
Chris@16
|
1063 unordered_set<T,H,P,A>::unordered_set(
|
Chris@16
|
1064 std::initializer_list<value_type> list, size_type n,
|
Chris@16
|
1065 const hasher &hf, const key_equal &eql, const allocator_type &a)
|
Chris@16
|
1066 : table_(
|
Chris@16
|
1067 boost::unordered::detail::initial_size(
|
Chris@16
|
1068 list.begin(), list.end(), n),
|
Chris@16
|
1069 hf, eql, a)
|
Chris@16
|
1070 {
|
Chris@16
|
1071 table_.insert_range(list.begin(), list.end());
|
Chris@16
|
1072 }
|
Chris@16
|
1073
|
Chris@16
|
1074 template <class T, class H, class P, class A>
|
Chris@16
|
1075 unordered_set<T,H,P,A>& unordered_set<T,H,P,A>::operator=(
|
Chris@16
|
1076 std::initializer_list<value_type> list)
|
Chris@16
|
1077 {
|
Chris@16
|
1078 table_.clear();
|
Chris@16
|
1079 table_.insert_range(list.begin(), list.end());
|
Chris@16
|
1080 return *this;
|
Chris@16
|
1081 }
|
Chris@16
|
1082
|
Chris@16
|
1083 #endif
|
Chris@16
|
1084
|
Chris@16
|
1085 // size and capacity
|
Chris@16
|
1086
|
Chris@16
|
1087 template <class T, class H, class P, class A>
|
Chris@16
|
1088 std::size_t unordered_set<T,H,P,A>::max_size() const BOOST_NOEXCEPT
|
Chris@16
|
1089 {
|
Chris@16
|
1090 return table_.max_size();
|
Chris@16
|
1091 }
|
Chris@16
|
1092
|
Chris@16
|
1093 // modifiers
|
Chris@16
|
1094
|
Chris@16
|
1095 template <class T, class H, class P, class A>
|
Chris@16
|
1096 template <class InputIt>
|
Chris@16
|
1097 void unordered_set<T,H,P,A>::insert(InputIt first, InputIt last)
|
Chris@16
|
1098 {
|
Chris@16
|
1099 table_.insert_range(first, last);
|
Chris@16
|
1100 }
|
Chris@16
|
1101
|
Chris@16
|
1102 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
Chris@16
|
1103 template <class T, class H, class P, class A>
|
Chris@16
|
1104 void unordered_set<T,H,P,A>::insert(
|
Chris@16
|
1105 std::initializer_list<value_type> list)
|
Chris@16
|
1106 {
|
Chris@16
|
1107 table_.insert_range(list.begin(), list.end());
|
Chris@16
|
1108 }
|
Chris@16
|
1109 #endif
|
Chris@16
|
1110
|
Chris@16
|
1111 template <class T, class H, class P, class A>
|
Chris@16
|
1112 typename unordered_set<T,H,P,A>::iterator
|
Chris@16
|
1113 unordered_set<T,H,P,A>::erase(const_iterator position)
|
Chris@16
|
1114 {
|
Chris@16
|
1115 return table_.erase(position);
|
Chris@16
|
1116 }
|
Chris@16
|
1117
|
Chris@16
|
1118 template <class T, class H, class P, class A>
|
Chris@16
|
1119 typename unordered_set<T,H,P,A>::size_type
|
Chris@16
|
1120 unordered_set<T,H,P,A>::erase(const key_type& k)
|
Chris@16
|
1121 {
|
Chris@16
|
1122 return table_.erase_key(k);
|
Chris@16
|
1123 }
|
Chris@16
|
1124
|
Chris@16
|
1125 template <class T, class H, class P, class A>
|
Chris@16
|
1126 typename unordered_set<T,H,P,A>::iterator
|
Chris@16
|
1127 unordered_set<T,H,P,A>::erase(
|
Chris@16
|
1128 const_iterator first, const_iterator last)
|
Chris@16
|
1129 {
|
Chris@16
|
1130 return table_.erase_range(first, last);
|
Chris@16
|
1131 }
|
Chris@16
|
1132
|
Chris@16
|
1133 template <class T, class H, class P, class A>
|
Chris@16
|
1134 void unordered_set<T,H,P,A>::clear()
|
Chris@16
|
1135 {
|
Chris@16
|
1136 table_.clear();
|
Chris@16
|
1137 }
|
Chris@16
|
1138
|
Chris@16
|
1139 template <class T, class H, class P, class A>
|
Chris@16
|
1140 void unordered_set<T,H,P,A>::swap(unordered_set& other)
|
Chris@16
|
1141 {
|
Chris@16
|
1142 table_.swap(other.table_);
|
Chris@16
|
1143 }
|
Chris@16
|
1144
|
Chris@16
|
1145 // observers
|
Chris@16
|
1146
|
Chris@16
|
1147 template <class T, class H, class P, class A>
|
Chris@16
|
1148 typename unordered_set<T,H,P,A>::hasher
|
Chris@16
|
1149 unordered_set<T,H,P,A>::hash_function() const
|
Chris@16
|
1150 {
|
Chris@16
|
1151 return table_.hash_function();
|
Chris@16
|
1152 }
|
Chris@16
|
1153
|
Chris@16
|
1154 template <class T, class H, class P, class A>
|
Chris@16
|
1155 typename unordered_set<T,H,P,A>::key_equal
|
Chris@16
|
1156 unordered_set<T,H,P,A>::key_eq() const
|
Chris@16
|
1157 {
|
Chris@16
|
1158 return table_.key_eq();
|
Chris@16
|
1159 }
|
Chris@16
|
1160
|
Chris@16
|
1161 // lookup
|
Chris@16
|
1162
|
Chris@16
|
1163 template <class T, class H, class P, class A>
|
Chris@16
|
1164 typename unordered_set<T,H,P,A>::const_iterator
|
Chris@16
|
1165 unordered_set<T,H,P,A>::find(const key_type& k) const
|
Chris@16
|
1166 {
|
Chris@16
|
1167 return table_.find_node(k);
|
Chris@16
|
1168 }
|
Chris@16
|
1169
|
Chris@16
|
1170 template <class T, class H, class P, class A>
|
Chris@16
|
1171 template <class CompatibleKey, class CompatibleHash,
|
Chris@16
|
1172 class CompatiblePredicate>
|
Chris@16
|
1173 typename unordered_set<T,H,P,A>::const_iterator
|
Chris@16
|
1174 unordered_set<T,H,P,A>::find(
|
Chris@16
|
1175 CompatibleKey const& k,
|
Chris@16
|
1176 CompatibleHash const& hash,
|
Chris@16
|
1177 CompatiblePredicate const& eq) const
|
Chris@16
|
1178 {
|
Chris@16
|
1179 return table_.generic_find_node(k, hash, eq);
|
Chris@16
|
1180 }
|
Chris@16
|
1181
|
Chris@16
|
1182 template <class T, class H, class P, class A>
|
Chris@16
|
1183 typename unordered_set<T,H,P,A>::size_type
|
Chris@16
|
1184 unordered_set<T,H,P,A>::count(const key_type& k) const
|
Chris@16
|
1185 {
|
Chris@16
|
1186 return table_.count(k);
|
Chris@16
|
1187 }
|
Chris@16
|
1188
|
Chris@16
|
1189 template <class T, class H, class P, class A>
|
Chris@16
|
1190 std::pair<
|
Chris@16
|
1191 typename unordered_set<T,H,P,A>::const_iterator,
|
Chris@16
|
1192 typename unordered_set<T,H,P,A>::const_iterator>
|
Chris@16
|
1193 unordered_set<T,H,P,A>::equal_range(const key_type& k) const
|
Chris@16
|
1194 {
|
Chris@16
|
1195 return table_.equal_range(k);
|
Chris@16
|
1196 }
|
Chris@16
|
1197
|
Chris@16
|
1198 template <class T, class H, class P, class A>
|
Chris@16
|
1199 typename unordered_set<T,H,P,A>::size_type
|
Chris@16
|
1200 unordered_set<T,H,P,A>::bucket_size(size_type n) const
|
Chris@16
|
1201 {
|
Chris@16
|
1202 return table_.bucket_size(n);
|
Chris@16
|
1203 }
|
Chris@16
|
1204
|
Chris@16
|
1205 // hash policy
|
Chris@16
|
1206
|
Chris@16
|
1207 template <class T, class H, class P, class A>
|
Chris@16
|
1208 float unordered_set<T,H,P,A>::load_factor() const BOOST_NOEXCEPT
|
Chris@16
|
1209 {
|
Chris@16
|
1210 return table_.load_factor();
|
Chris@16
|
1211 }
|
Chris@16
|
1212
|
Chris@16
|
1213 template <class T, class H, class P, class A>
|
Chris@16
|
1214 void unordered_set<T,H,P,A>::max_load_factor(float m) BOOST_NOEXCEPT
|
Chris@16
|
1215 {
|
Chris@16
|
1216 table_.max_load_factor(m);
|
Chris@16
|
1217 }
|
Chris@16
|
1218
|
Chris@16
|
1219 template <class T, class H, class P, class A>
|
Chris@16
|
1220 void unordered_set<T,H,P,A>::rehash(size_type n)
|
Chris@16
|
1221 {
|
Chris@16
|
1222 table_.rehash(n);
|
Chris@16
|
1223 }
|
Chris@16
|
1224
|
Chris@16
|
1225 template <class T, class H, class P, class A>
|
Chris@16
|
1226 void unordered_set<T,H,P,A>::reserve(size_type n)
|
Chris@16
|
1227 {
|
Chris@16
|
1228 table_.reserve(n);
|
Chris@16
|
1229 }
|
Chris@16
|
1230
|
Chris@16
|
1231 template <class T, class H, class P, class A>
|
Chris@16
|
1232 inline bool operator==(
|
Chris@16
|
1233 unordered_set<T,H,P,A> const& m1,
|
Chris@16
|
1234 unordered_set<T,H,P,A> const& m2)
|
Chris@16
|
1235 {
|
Chris@16
|
1236 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
|
Chris@16
|
1237 struct dummy { unordered_set<T,H,P,A> x; };
|
Chris@16
|
1238 #endif
|
Chris@16
|
1239 return m1.table_.equals(m2.table_);
|
Chris@16
|
1240 }
|
Chris@16
|
1241
|
Chris@16
|
1242 template <class T, class H, class P, class A>
|
Chris@16
|
1243 inline bool operator!=(
|
Chris@16
|
1244 unordered_set<T,H,P,A> const& m1,
|
Chris@16
|
1245 unordered_set<T,H,P,A> const& m2)
|
Chris@16
|
1246 {
|
Chris@16
|
1247 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
|
Chris@16
|
1248 struct dummy { unordered_set<T,H,P,A> x; };
|
Chris@16
|
1249 #endif
|
Chris@16
|
1250 return !m1.table_.equals(m2.table_);
|
Chris@16
|
1251 }
|
Chris@16
|
1252
|
Chris@16
|
1253 template <class T, class H, class P, class A>
|
Chris@16
|
1254 inline void swap(
|
Chris@16
|
1255 unordered_set<T,H,P,A> &m1,
|
Chris@16
|
1256 unordered_set<T,H,P,A> &m2)
|
Chris@16
|
1257 {
|
Chris@16
|
1258 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
|
Chris@16
|
1259 struct dummy { unordered_set<T,H,P,A> x; };
|
Chris@16
|
1260 #endif
|
Chris@16
|
1261 m1.swap(m2);
|
Chris@16
|
1262 }
|
Chris@16
|
1263
|
Chris@16
|
1264 ////////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
1265
|
Chris@16
|
1266 template <class T, class H, class P, class A>
|
Chris@16
|
1267 unordered_multiset<T,H,P,A>::unordered_multiset(
|
Chris@16
|
1268 size_type n, const hasher &hf, const key_equal &eql,
|
Chris@16
|
1269 const allocator_type &a)
|
Chris@16
|
1270 : table_(n, hf, eql, a)
|
Chris@16
|
1271 {
|
Chris@16
|
1272 }
|
Chris@16
|
1273
|
Chris@16
|
1274 template <class T, class H, class P, class A>
|
Chris@16
|
1275 unordered_multiset<T,H,P,A>::unordered_multiset(allocator_type const& a)
|
Chris@16
|
1276 : table_(boost::unordered::detail::default_bucket_count,
|
Chris@16
|
1277 hasher(), key_equal(), a)
|
Chris@16
|
1278 {
|
Chris@16
|
1279 }
|
Chris@16
|
1280
|
Chris@16
|
1281 template <class T, class H, class P, class A>
|
Chris@16
|
1282 unordered_multiset<T,H,P,A>::unordered_multiset(
|
Chris@16
|
1283 unordered_multiset const& other, allocator_type const& a)
|
Chris@16
|
1284 : table_(other.table_, a)
|
Chris@16
|
1285 {
|
Chris@16
|
1286 }
|
Chris@16
|
1287
|
Chris@16
|
1288 template <class T, class H, class P, class A>
|
Chris@16
|
1289 template <class InputIt>
|
Chris@16
|
1290 unordered_multiset<T,H,P,A>::unordered_multiset(InputIt f, InputIt l)
|
Chris@16
|
1291 : table_(boost::unordered::detail::initial_size(f, l),
|
Chris@16
|
1292 hasher(), key_equal(), allocator_type())
|
Chris@16
|
1293 {
|
Chris@16
|
1294 table_.insert_range(f, l);
|
Chris@16
|
1295 }
|
Chris@16
|
1296
|
Chris@16
|
1297 template <class T, class H, class P, class A>
|
Chris@16
|
1298 template <class InputIt>
|
Chris@16
|
1299 unordered_multiset<T,H,P,A>::unordered_multiset(
|
Chris@16
|
1300 InputIt f, InputIt l,
|
Chris@16
|
1301 size_type n,
|
Chris@16
|
1302 const hasher &hf,
|
Chris@16
|
1303 const key_equal &eql)
|
Chris@16
|
1304 : table_(boost::unordered::detail::initial_size(f, l, n),
|
Chris@16
|
1305 hf, eql, allocator_type())
|
Chris@16
|
1306 {
|
Chris@16
|
1307 table_.insert_range(f, l);
|
Chris@16
|
1308 }
|
Chris@16
|
1309
|
Chris@16
|
1310 template <class T, class H, class P, class A>
|
Chris@16
|
1311 template <class InputIt>
|
Chris@16
|
1312 unordered_multiset<T,H,P,A>::unordered_multiset(
|
Chris@16
|
1313 InputIt f, InputIt l,
|
Chris@16
|
1314 size_type n,
|
Chris@16
|
1315 const hasher &hf,
|
Chris@16
|
1316 const key_equal &eql,
|
Chris@16
|
1317 const allocator_type &a)
|
Chris@16
|
1318 : table_(boost::unordered::detail::initial_size(f, l, n), hf, eql, a)
|
Chris@16
|
1319 {
|
Chris@16
|
1320 table_.insert_range(f, l);
|
Chris@16
|
1321 }
|
Chris@16
|
1322
|
Chris@16
|
1323 template <class T, class H, class P, class A>
|
Chris@16
|
1324 unordered_multiset<T,H,P,A>::~unordered_multiset() BOOST_NOEXCEPT {}
|
Chris@16
|
1325
|
Chris@16
|
1326 template <class T, class H, class P, class A>
|
Chris@16
|
1327 unordered_multiset<T,H,P,A>::unordered_multiset(
|
Chris@16
|
1328 unordered_multiset const& other)
|
Chris@16
|
1329 : table_(other.table_)
|
Chris@16
|
1330 {
|
Chris@16
|
1331 }
|
Chris@16
|
1332
|
Chris@16
|
1333 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
Chris@16
|
1334
|
Chris@16
|
1335 template <class T, class H, class P, class A>
|
Chris@16
|
1336 unordered_multiset<T,H,P,A>::unordered_multiset(
|
Chris@16
|
1337 unordered_multiset&& other, allocator_type const& a)
|
Chris@16
|
1338 : table_(other.table_, a, boost::unordered::detail::move_tag())
|
Chris@16
|
1339 {
|
Chris@16
|
1340 }
|
Chris@16
|
1341
|
Chris@16
|
1342 #endif
|
Chris@16
|
1343
|
Chris@16
|
1344 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
Chris@16
|
1345
|
Chris@16
|
1346 template <class T, class H, class P, class A>
|
Chris@16
|
1347 unordered_multiset<T,H,P,A>::unordered_multiset(
|
Chris@16
|
1348 std::initializer_list<value_type> list, size_type n,
|
Chris@16
|
1349 const hasher &hf, const key_equal &eql, const allocator_type &a)
|
Chris@16
|
1350 : table_(
|
Chris@16
|
1351 boost::unordered::detail::initial_size(
|
Chris@16
|
1352 list.begin(), list.end(), n),
|
Chris@16
|
1353 hf, eql, a)
|
Chris@16
|
1354 {
|
Chris@16
|
1355 table_.insert_range(list.begin(), list.end());
|
Chris@16
|
1356 }
|
Chris@16
|
1357
|
Chris@16
|
1358 template <class T, class H, class P, class A>
|
Chris@16
|
1359 unordered_multiset<T,H,P,A>& unordered_multiset<T,H,P,A>::operator=(
|
Chris@16
|
1360 std::initializer_list<value_type> list)
|
Chris@16
|
1361 {
|
Chris@16
|
1362 table_.clear();
|
Chris@16
|
1363 table_.insert_range(list.begin(), list.end());
|
Chris@16
|
1364 return *this;
|
Chris@16
|
1365 }
|
Chris@16
|
1366
|
Chris@16
|
1367 #endif
|
Chris@16
|
1368
|
Chris@16
|
1369 // size and capacity
|
Chris@16
|
1370
|
Chris@16
|
1371 template <class T, class H, class P, class A>
|
Chris@16
|
1372 std::size_t unordered_multiset<T,H,P,A>::max_size() const BOOST_NOEXCEPT
|
Chris@16
|
1373 {
|
Chris@16
|
1374 return table_.max_size();
|
Chris@16
|
1375 }
|
Chris@16
|
1376
|
Chris@16
|
1377 // modifiers
|
Chris@16
|
1378
|
Chris@16
|
1379 template <class T, class H, class P, class A>
|
Chris@16
|
1380 template <class InputIt>
|
Chris@16
|
1381 void unordered_multiset<T,H,P,A>::insert(InputIt first, InputIt last)
|
Chris@16
|
1382 {
|
Chris@16
|
1383 table_.insert_range(first, last);
|
Chris@16
|
1384 }
|
Chris@16
|
1385
|
Chris@16
|
1386 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
Chris@16
|
1387 template <class T, class H, class P, class A>
|
Chris@16
|
1388 void unordered_multiset<T,H,P,A>::insert(
|
Chris@16
|
1389 std::initializer_list<value_type> list)
|
Chris@16
|
1390 {
|
Chris@16
|
1391 table_.insert_range(list.begin(), list.end());
|
Chris@16
|
1392 }
|
Chris@16
|
1393 #endif
|
Chris@16
|
1394
|
Chris@16
|
1395 template <class T, class H, class P, class A>
|
Chris@16
|
1396 typename unordered_multiset<T,H,P,A>::iterator
|
Chris@16
|
1397 unordered_multiset<T,H,P,A>::erase(const_iterator position)
|
Chris@16
|
1398 {
|
Chris@16
|
1399 return table_.erase(position);
|
Chris@16
|
1400 }
|
Chris@16
|
1401
|
Chris@16
|
1402 template <class T, class H, class P, class A>
|
Chris@16
|
1403 typename unordered_multiset<T,H,P,A>::size_type
|
Chris@16
|
1404 unordered_multiset<T,H,P,A>::erase(const key_type& k)
|
Chris@16
|
1405 {
|
Chris@16
|
1406 return table_.erase_key(k);
|
Chris@16
|
1407 }
|
Chris@16
|
1408
|
Chris@16
|
1409 template <class T, class H, class P, class A>
|
Chris@16
|
1410 typename unordered_multiset<T,H,P,A>::iterator
|
Chris@16
|
1411 unordered_multiset<T,H,P,A>::erase(
|
Chris@16
|
1412 const_iterator first, const_iterator last)
|
Chris@16
|
1413 {
|
Chris@16
|
1414 return table_.erase_range(first, last);
|
Chris@16
|
1415 }
|
Chris@16
|
1416
|
Chris@16
|
1417 template <class T, class H, class P, class A>
|
Chris@16
|
1418 void unordered_multiset<T,H,P,A>::clear()
|
Chris@16
|
1419 {
|
Chris@16
|
1420 table_.clear();
|
Chris@16
|
1421 }
|
Chris@16
|
1422
|
Chris@16
|
1423 template <class T, class H, class P, class A>
|
Chris@16
|
1424 void unordered_multiset<T,H,P,A>::swap(unordered_multiset& other)
|
Chris@16
|
1425 {
|
Chris@16
|
1426 table_.swap(other.table_);
|
Chris@16
|
1427 }
|
Chris@16
|
1428
|
Chris@16
|
1429 // observers
|
Chris@16
|
1430
|
Chris@16
|
1431 template <class T, class H, class P, class A>
|
Chris@16
|
1432 typename unordered_multiset<T,H,P,A>::hasher
|
Chris@16
|
1433 unordered_multiset<T,H,P,A>::hash_function() const
|
Chris@16
|
1434 {
|
Chris@16
|
1435 return table_.hash_function();
|
Chris@16
|
1436 }
|
Chris@16
|
1437
|
Chris@16
|
1438 template <class T, class H, class P, class A>
|
Chris@16
|
1439 typename unordered_multiset<T,H,P,A>::key_equal
|
Chris@16
|
1440 unordered_multiset<T,H,P,A>::key_eq() const
|
Chris@16
|
1441 {
|
Chris@16
|
1442 return table_.key_eq();
|
Chris@16
|
1443 }
|
Chris@16
|
1444
|
Chris@16
|
1445 // lookup
|
Chris@16
|
1446
|
Chris@16
|
1447 template <class T, class H, class P, class A>
|
Chris@16
|
1448 typename unordered_multiset<T,H,P,A>::const_iterator
|
Chris@16
|
1449 unordered_multiset<T,H,P,A>::find(const key_type& k) const
|
Chris@16
|
1450 {
|
Chris@16
|
1451 return table_.find_node(k);
|
Chris@16
|
1452 }
|
Chris@16
|
1453
|
Chris@16
|
1454 template <class T, class H, class P, class A>
|
Chris@16
|
1455 template <class CompatibleKey, class CompatibleHash,
|
Chris@16
|
1456 class CompatiblePredicate>
|
Chris@16
|
1457 typename unordered_multiset<T,H,P,A>::const_iterator
|
Chris@16
|
1458 unordered_multiset<T,H,P,A>::find(
|
Chris@16
|
1459 CompatibleKey const& k,
|
Chris@16
|
1460 CompatibleHash const& hash,
|
Chris@16
|
1461 CompatiblePredicate const& eq) const
|
Chris@16
|
1462 {
|
Chris@16
|
1463 return table_.generic_find_node(k, hash, eq);
|
Chris@16
|
1464 }
|
Chris@16
|
1465
|
Chris@16
|
1466 template <class T, class H, class P, class A>
|
Chris@16
|
1467 typename unordered_multiset<T,H,P,A>::size_type
|
Chris@16
|
1468 unordered_multiset<T,H,P,A>::count(const key_type& k) const
|
Chris@16
|
1469 {
|
Chris@16
|
1470 return table_.count(k);
|
Chris@16
|
1471 }
|
Chris@16
|
1472
|
Chris@16
|
1473 template <class T, class H, class P, class A>
|
Chris@16
|
1474 std::pair<
|
Chris@16
|
1475 typename unordered_multiset<T,H,P,A>::const_iterator,
|
Chris@16
|
1476 typename unordered_multiset<T,H,P,A>::const_iterator>
|
Chris@16
|
1477 unordered_multiset<T,H,P,A>::equal_range(const key_type& k) const
|
Chris@16
|
1478 {
|
Chris@16
|
1479 return table_.equal_range(k);
|
Chris@16
|
1480 }
|
Chris@16
|
1481
|
Chris@16
|
1482 template <class T, class H, class P, class A>
|
Chris@16
|
1483 typename unordered_multiset<T,H,P,A>::size_type
|
Chris@16
|
1484 unordered_multiset<T,H,P,A>::bucket_size(size_type n) const
|
Chris@16
|
1485 {
|
Chris@16
|
1486 return table_.bucket_size(n);
|
Chris@16
|
1487 }
|
Chris@16
|
1488
|
Chris@16
|
1489 // hash policy
|
Chris@16
|
1490
|
Chris@16
|
1491 template <class T, class H, class P, class A>
|
Chris@16
|
1492 float unordered_multiset<T,H,P,A>::load_factor() const BOOST_NOEXCEPT
|
Chris@16
|
1493 {
|
Chris@16
|
1494 return table_.load_factor();
|
Chris@16
|
1495 }
|
Chris@16
|
1496
|
Chris@16
|
1497 template <class T, class H, class P, class A>
|
Chris@16
|
1498 void unordered_multiset<T,H,P,A>::max_load_factor(float m) BOOST_NOEXCEPT
|
Chris@16
|
1499 {
|
Chris@16
|
1500 table_.max_load_factor(m);
|
Chris@16
|
1501 }
|
Chris@16
|
1502
|
Chris@16
|
1503 template <class T, class H, class P, class A>
|
Chris@16
|
1504 void unordered_multiset<T,H,P,A>::rehash(size_type n)
|
Chris@16
|
1505 {
|
Chris@16
|
1506 table_.rehash(n);
|
Chris@16
|
1507 }
|
Chris@16
|
1508
|
Chris@16
|
1509 template <class T, class H, class P, class A>
|
Chris@16
|
1510 void unordered_multiset<T,H,P,A>::reserve(size_type n)
|
Chris@16
|
1511 {
|
Chris@16
|
1512 table_.reserve(n);
|
Chris@16
|
1513 }
|
Chris@16
|
1514
|
Chris@16
|
1515 template <class T, class H, class P, class A>
|
Chris@16
|
1516 inline bool operator==(
|
Chris@16
|
1517 unordered_multiset<T,H,P,A> const& m1,
|
Chris@16
|
1518 unordered_multiset<T,H,P,A> const& m2)
|
Chris@16
|
1519 {
|
Chris@16
|
1520 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
|
Chris@16
|
1521 struct dummy { unordered_multiset<T,H,P,A> x; };
|
Chris@16
|
1522 #endif
|
Chris@16
|
1523 return m1.table_.equals(m2.table_);
|
Chris@16
|
1524 }
|
Chris@16
|
1525
|
Chris@16
|
1526 template <class T, class H, class P, class A>
|
Chris@16
|
1527 inline bool operator!=(
|
Chris@16
|
1528 unordered_multiset<T,H,P,A> const& m1,
|
Chris@16
|
1529 unordered_multiset<T,H,P,A> const& m2)
|
Chris@16
|
1530 {
|
Chris@16
|
1531 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
|
Chris@16
|
1532 struct dummy { unordered_multiset<T,H,P,A> x; };
|
Chris@16
|
1533 #endif
|
Chris@16
|
1534 return !m1.table_.equals(m2.table_);
|
Chris@16
|
1535 }
|
Chris@16
|
1536
|
Chris@16
|
1537 template <class T, class H, class P, class A>
|
Chris@16
|
1538 inline void swap(
|
Chris@16
|
1539 unordered_multiset<T,H,P,A> &m1,
|
Chris@16
|
1540 unordered_multiset<T,H,P,A> &m2)
|
Chris@16
|
1541 {
|
Chris@16
|
1542 #if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x0613))
|
Chris@16
|
1543 struct dummy { unordered_multiset<T,H,P,A> x; };
|
Chris@16
|
1544 #endif
|
Chris@16
|
1545 m1.swap(m2);
|
Chris@16
|
1546 }
|
Chris@16
|
1547 } // namespace unordered
|
Chris@16
|
1548 } // namespace boost
|
Chris@16
|
1549
|
Chris@16
|
1550 #if defined(BOOST_MSVC)
|
Chris@16
|
1551 #pragma warning(pop)
|
Chris@16
|
1552 #endif
|
Chris@16
|
1553
|
Chris@16
|
1554 #endif // BOOST_UNORDERED_UNORDERED_SET_HPP_INCLUDED
|