28 #ifndef _GLIBCXX_PROFILE_UNORDERED_MAP
29 #define _GLIBCXX_PROFILE_UNORDERED_MAP 1
31 #if __cplusplus < 201103L
39 #define _GLIBCXX_BASE unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>
40 #define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE
42 namespace std _GLIBCXX_VISIBILITY(default)
47 template<
typename _Key,
typename _Tp,
52 :
public _GLIBCXX_STD_BASE,
53 public _Unordered_profile<unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>,
56 typedef typename _GLIBCXX_STD_BASE
_Base;
59 _M_base() noexcept {
return *
this; }
62 _M_base()
const noexcept {
return *
this; }
65 typedef typename _Base::size_type size_type;
66 typedef typename _Base::hasher hasher;
67 typedef typename _Base::key_equal key_equal;
68 typedef typename _Base::allocator_type allocator_type;
69 typedef typename _Base::key_type key_type;
70 typedef typename _Base::value_type value_type;
71 typedef typename _Base::difference_type difference_type;
72 typedef typename _Base::reference reference;
73 typedef typename _Base::const_reference const_reference;
74 typedef typename _Base::mapped_type mapped_type;
76 typedef typename _Base::iterator iterator;
77 typedef typename _Base::const_iterator const_iterator;
83 const hasher& __hf = hasher(),
84 const key_equal& __eql = key_equal(),
85 const allocator_type& __a = allocator_type())
86 : _Base(__n, __hf, __eql, __a) { }
88 template<
typename _InputIterator>
91 const hasher& __hf = hasher(),
92 const key_equal& __eql = key_equal(),
93 const allocator_type& __a = allocator_type())
94 : _Base(__f, __l, __n, __hf, __eql, __a) { }
108 const allocator_type& __a)
109 : _Base(__umap, __a) { }
112 const allocator_type& __a)
113 : _Base(std::move(__umap._M_base()), __a) { }
117 const hasher& __hf = hasher(),
118 const key_equal& __eql = key_equal(),
119 const allocator_type& __a = allocator_type())
120 : _Base(__l, __n, __hf, __eql, __a) { }
127 const allocator_type& __a)
131 template<
typename _InputIterator>
134 const allocator_type& __a)
135 :
unordered_map(__first, __last, __n, hasher(), key_equal(), __a)
138 template<
typename _InputIterator>
140 size_type __n,
const hasher& __hf,
141 const allocator_type& __a)
142 :
unordered_map(__first, __last, __n, __hf, key_equal(), __a)
147 const allocator_type& __a)
152 size_type __n,
const hasher& __hf,
153 const allocator_type& __a)
166 this->_M_profile_destruct();
168 this->_M_profile_construct();
175 this->_M_profile_destruct();
177 this->_M_profile_construct();
180 template<
typename... _Args>
182 emplace(_Args&&... __args)
184 size_type __old_size = _Base::bucket_count();
186 = _Base::emplace(std::forward<_Args>(__args)...);
187 this->_M_profile_resize(__old_size);
191 template<
typename... _Args>
193 emplace_hint(const_iterator __it, _Args&&... __args)
195 size_type __old_size = _Base::bucket_count();
197 = _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
198 this->_M_profile_resize(__old_size);
205 size_type __old_size = _Base::bucket_count();
207 this->_M_profile_resize(__old_size);
211 insert(
const value_type& __obj)
213 size_type __old_size = _Base::bucket_count();
215 this->_M_profile_resize(__old_size);
220 insert(const_iterator __iter,
const value_type& __v)
222 size_type __old_size = _Base::bucket_count();
223 iterator __res = _Base::insert(__iter, __v);
224 this->_M_profile_resize(__old_size);
228 template<
typename _Pair,
typename =
typename
229 std::enable_if<std::is_constructible<value_type,
230 _Pair&&>::value>::type>
232 insert(_Pair&& __obj)
234 size_type __old_size = _Base::bucket_count();
236 = _Base::insert(std::forward<_Pair>(__obj));
237 this->_M_profile_resize(__old_size);
241 template<
typename _Pair,
typename =
typename
242 std::enable_if<std::is_constructible<value_type,
243 _Pair&&>::value>::type>
245 insert(const_iterator __iter, _Pair&& __v)
247 size_type __old_size = _Base::bucket_count();
248 iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
249 this->_M_profile_resize(__old_size);
253 template<
typename _InputIter>
255 insert(_InputIter __first, _InputIter __last)
257 size_type __old_size = _Base::bucket_count();
258 _Base::insert(__first, __last);
259 this->_M_profile_resize(__old_size);
264 operator[](
const _Key& __k)
266 size_type __old_size = _Base::bucket_count();
267 mapped_type& __res = _M_base()[__k];
268 this->_M_profile_resize(__old_size);
273 operator[](_Key&& __k)
275 size_type __old_size = _Base::bucket_count();
276 mapped_type& __res = _M_base()[std::move(__k)];
277 this->_M_profile_resize(__old_size);
283 noexcept( noexcept(__x._M_base().swap(__x)) )
285 _Base::swap(__x._M_base());
289 void rehash(size_type __n)
291 size_type __old_size = _Base::bucket_count();
293 this->_M_profile_resize(__old_size);
297 template<
typename _Key,
typename _Tp,
typename _Hash,
298 typename _Pred,
typename _Alloc>
304 template<
typename _Key,
typename _Tp,
typename _Hash,
305 typename _Pred,
typename _Alloc>
309 {
return static_cast<const _GLIBCXX_STD_BASE&
>(__x) == __y; }
311 template<
typename _Key,
typename _Tp,
typename _Hash,
312 typename _Pred,
typename _Alloc>
314 operator!=(
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
315 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
316 {
return !(__x == __y); }
319 #undef _GLIBCXX_STD_BASE
320 #define _GLIBCXX_BASE unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>
321 #define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE
324 template<
typename _Key,
typename _Tp,
329 :
public _GLIBCXX_STD_BASE,
330 public _Unordered_profile<unordered_multimap<_Key, _Tp,
331 _Hash, _Pred, _Alloc>,
334 typedef typename _GLIBCXX_STD_BASE
_Base;
337 _M_base() noexcept {
return *
this; }
340 _M_base()
const noexcept {
return *
this; }
343 typedef typename _Base::size_type size_type;
344 typedef typename _Base::hasher hasher;
345 typedef typename _Base::key_equal key_equal;
346 typedef typename _Base::allocator_type allocator_type;
347 typedef typename _Base::key_type key_type;
348 typedef typename _Base::value_type value_type;
349 typedef typename _Base::difference_type difference_type;
350 typedef typename _Base::reference reference;
351 typedef typename _Base::const_reference const_reference;
353 typedef typename _Base::iterator iterator;
354 typedef typename _Base::const_iterator const_iterator;
360 const hasher& __hf = hasher(),
361 const key_equal& __eql = key_equal(),
362 const allocator_type& __a = allocator_type())
363 : _Base(__n, __hf, __eql, __a) { }
365 template<
typename _InputIterator>
368 const hasher& __hf = hasher(),
369 const key_equal& __eql = key_equal(),
370 const allocator_type& __a = allocator_type())
371 : _Base(__f, __l, __n, __hf, __eql, __a) { }
385 const allocator_type& __a)
386 : _Base(__ummap._M_base(), __a) { }
389 const allocator_type& __a)
390 : _Base(std::move(__ummap._M_base()), __a) { }
394 const hasher& __hf = hasher(),
395 const key_equal& __eql = key_equal(),
396 const allocator_type& __a = allocator_type())
397 : _Base(__l, __n, __hf, __eql, __a) { }
404 const allocator_type& __a)
408 template<
typename _InputIterator>
411 const allocator_type& __a)
415 template<
typename _InputIterator>
417 size_type __n,
const hasher& __hf,
418 const allocator_type& __a)
424 const allocator_type& __a)
429 size_type __n,
const hasher& __hf,
430 const allocator_type& __a)
443 this->_M_profile_destruct();
445 this->_M_profile_construct();
452 this->_M_profile_destruct();
454 this->_M_profile_construct();
457 template<
typename... _Args>
459 emplace(_Args&&... __args)
461 size_type __old_size = _Base::bucket_count();
463 = _Base::emplace(std::forward<_Args>(__args)...);
464 this->_M_profile_resize(__old_size);
468 template<
typename... _Args>
470 emplace_hint(const_iterator __it, _Args&&... __args)
472 size_type __old_size = _Base::bucket_count();
474 = _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
475 this->_M_profile_resize(__old_size);
482 size_type __old_size = _Base::bucket_count();
484 this->_M_profile_resize(__old_size);
488 insert(
const value_type& __obj)
490 size_type __old_size = _Base::bucket_count();
491 iterator __res = _Base::insert(__obj);
492 this->_M_profile_resize(__old_size);
497 insert(const_iterator __iter,
const value_type& __v)
499 size_type __old_size = _Base::bucket_count();
500 iterator __res = _Base::insert(__iter, __v);
501 this->_M_profile_resize(__old_size);
505 template<
typename _Pair,
typename =
typename
506 std::enable_if<std::is_constructible<value_type,
507 _Pair&&>::value>::type>
509 insert(_Pair&& __obj)
511 size_type __old_size = _Base::bucket_count();
512 iterator __res = _Base::insert(std::forward<_Pair>(__obj));
513 this->_M_profile_resize(__old_size);
517 template<
typename _Pair,
typename =
typename
518 std::enable_if<std::is_constructible<value_type,
519 _Pair&&>::value>::type>
521 insert(const_iterator __iter, _Pair&& __v)
523 size_type __old_size = _Base::bucket_count();
524 iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
525 this->_M_profile_resize(__old_size);
529 template<
typename _InputIter>
531 insert(_InputIter __first, _InputIter __last)
533 size_type __old_size = _Base::bucket_count();
534 _Base::insert(__first, __last);
535 this->_M_profile_resize(__old_size);
540 noexcept( noexcept(__x._M_base().swap(__x)) )
542 _Base::swap(__x._M_base());
547 rehash(size_type __n)
549 size_type __old_size = _Base::bucket_count();
551 this->_M_profile_resize(__old_size);
555 template<
typename _Key,
typename _Tp,
typename _Hash,
556 typename _Pred,
typename _Alloc>
562 template<
typename _Key,
typename _Tp,
typename _Hash,
563 typename _Pred,
typename _Alloc>
567 {
return static_cast<const _GLIBCXX_STD_BASE&
>(__x) == __y; }
569 template<
typename _Key,
typename _Tp,
typename _Hash,
570 typename _Pred,
typename _Alloc>
572 operator!=(
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
573 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
574 {
return !(__x == __y); }
580 #undef _GLIBCXX_STD_BASE
Sequential helper functions. This file is a GNU profile extension to the Standard C++ Library...
Primary class template hash.
Class std::unordered_multimap wrapper with performance instrumentation.
A standard container composed of unique keys (containing at most one of each key value) that associat...
ISO C++ entities toplevel namespace is std.
A standard container composed of equivalent keys (possibly containing multiple of each key value) tha...
Class std::unordered_map wrapper with performance instrumentation.
One of the comparison functors.
Struct holding two objects of arbitrary type.
The standard allocator, as per [20.4].