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;
81 const hasher& __hf = hasher(),
82 const key_equal& __eql = key_equal(),
83 const allocator_type& __a = allocator_type())
84 :
_Base(__n, __hf, __eql, __a)
87 template<
typename _InputIterator>
90 const hasher& __hf = hasher(),
91 const key_equal& __eql = key_equal(),
92 const allocator_type& __a = allocator_type())
93 :
_Base(__f, __l, __n, __hf, __eql, __a)
110 const allocator_type& __a)
115 const allocator_type& __a)
116 :
_Base(std::move(__umap._M_base()), __a)
121 const hasher& __hf = hasher(),
122 const key_equal& __eql = key_equal(),
123 const allocator_type& __a = allocator_type())
124 :
_Base(__l, __n, __hf, __eql, __a)
143 __profcxx_hashtable_destruct(
this, _Base::bucket_count(),
145 this->_M_profile_destruct();
149 template<
typename... _Args>
151 emplace(_Args&&... __args)
153 size_type __old_size = _Base::bucket_count();
155 = _Base::emplace(std::forward<_Args>(__args)...);
156 _M_profile_resize(__old_size);
160 template<
typename... _Args>
162 emplace_hint(const_iterator __it, _Args&&... __args)
164 size_type __old_size = _Base::bucket_count();
166 = _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
167 _M_profile_resize(__old_size);
174 size_type __old_size = _Base::bucket_count();
176 _M_profile_resize(__old_size);
180 insert(
const value_type& __obj)
182 size_type __old_size = _Base::bucket_count();
184 _M_profile_resize(__old_size);
189 insert(const_iterator __iter,
const value_type& __v)
191 size_type __old_size = _Base::bucket_count();
192 iterator __res = _Base::insert(__iter, __v);
193 _M_profile_resize(__old_size);
197 template<
typename _Pair,
typename =
typename
198 std::enable_if<std::is_constructible<value_type,
199 _Pair&&>::value>::type>
201 insert(_Pair&& __obj)
203 size_type __old_size = _Base::bucket_count();
205 = _Base::insert(std::forward<_Pair>(__obj));
206 _M_profile_resize(__old_size);
210 template<
typename _Pair,
typename =
typename
211 std::enable_if<std::is_constructible<value_type,
212 _Pair&&>::value>::type>
214 insert(const_iterator __iter, _Pair&& __v)
216 size_type __old_size = _Base::bucket_count();
217 iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
218 _M_profile_resize(__old_size);
222 template<
typename _InputIter>
224 insert(_InputIter __first, _InputIter __last)
226 size_type __old_size = _Base::bucket_count();
227 _Base::insert(__first, __last);
228 _M_profile_resize(__old_size);
233 operator[](
const _Key& __k)
235 size_type __old_size = _Base::bucket_count();
236 mapped_type& __res = _M_base()[__k];
237 _M_profile_resize(__old_size);
242 operator[](_Key&& __k)
244 size_type __old_size = _Base::bucket_count();
245 mapped_type& __res = _M_base()[std::move(__k)];
246 _M_profile_resize(__old_size);
252 noexcept( noexcept(__x._M_base().swap(__x)) )
255 void rehash(size_type __n)
257 size_type __old_size = _Base::bucket_count();
259 _M_profile_resize(__old_size);
264 _M_profile_resize(size_type __old_size)
266 size_type __new_size = _Base::bucket_count();
267 if (__old_size != __new_size)
268 __profcxx_hashtable_resize(
this, __old_size, __new_size);
272 template<
typename _Key,
typename _Tp,
typename _Hash,
273 typename _Pred,
typename _Alloc>
279 template<
typename _Key,
typename _Tp,
typename _Hash,
280 typename _Pred,
typename _Alloc>
284 {
return static_cast<const _GLIBCXX_STD_BASE&
>(__x) == __y; }
286 template<
typename _Key,
typename _Tp,
typename _Hash,
287 typename _Pred,
typename _Alloc>
289 operator!=(
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
290 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
291 {
return !(__x == __y); }
294 #undef _GLIBCXX_STD_BASE
295 #define _GLIBCXX_BASE unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>
296 #define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE
299 template<
typename _Key,
typename _Tp,
304 :
public _GLIBCXX_STD_BASE,
305 public _Unordered_profile<unordered_multimap<_Key, _Tp,
306 _Hash, _Pred, _Alloc>,
309 typedef typename _GLIBCXX_STD_BASE
_Base;
312 _M_base() noexcept {
return *
this; }
315 _M_base()
const noexcept {
return *
this; }
318 typedef typename _Base::size_type size_type;
319 typedef typename _Base::hasher hasher;
320 typedef typename _Base::key_equal key_equal;
321 typedef typename _Base::allocator_type allocator_type;
322 typedef typename _Base::key_type key_type;
323 typedef typename _Base::value_type value_type;
324 typedef typename _Base::difference_type difference_type;
325 typedef typename _Base::reference reference;
326 typedef typename _Base::const_reference const_reference;
328 typedef typename _Base::iterator iterator;
329 typedef typename _Base::const_iterator const_iterator;
333 const hasher& __hf = hasher(),
334 const key_equal& __eql = key_equal(),
335 const allocator_type& __a = allocator_type())
336 :
_Base(__n, __hf, __eql, __a)
339 template<
typename _InputIterator>
342 const hasher& __hf = hasher(),
343 const key_equal& __eql = key_equal(),
344 const allocator_type& __a = allocator_type())
345 :
_Base(__f, __l, __n, __hf, __eql, __a)
362 const allocator_type& __a)
363 :
_Base(__ummap._M_base(), __a)
367 const allocator_type& __a)
368 :
_Base(std::move(__ummap._M_base()), __a)
373 const hasher& __hf = hasher(),
374 const key_equal& __eql = key_equal(),
375 const allocator_type& __a = allocator_type())
376 :
_Base(__l, __n, __hf, __eql, __a)
395 __profcxx_hashtable_destruct(
this, _Base::bucket_count(),
397 this->_M_profile_destruct();
401 template<
typename... _Args>
403 emplace(_Args&&... __args)
405 size_type __old_size = _Base::bucket_count();
407 = _Base::emplace(std::forward<_Args>(__args)...);
408 _M_profile_resize(__old_size);
412 template<
typename... _Args>
414 emplace_hint(const_iterator __it, _Args&&... __args)
416 size_type __old_size = _Base::bucket_count();
418 = _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
419 _M_profile_resize(__old_size);
426 size_type __old_size = _Base::bucket_count();
428 _M_profile_resize(__old_size);
432 insert(
const value_type& __obj)
434 size_type __old_size = _Base::bucket_count();
435 iterator __res = _Base::insert(__obj);
436 _M_profile_resize(__old_size);
441 insert(const_iterator __iter,
const value_type& __v)
443 size_type __old_size = _Base::bucket_count();
444 iterator __res = _Base::insert(__iter, __v);
445 _M_profile_resize(__old_size);
449 template<
typename _Pair,
typename =
typename
450 std::enable_if<std::is_constructible<value_type,
451 _Pair&&>::value>::type>
453 insert(_Pair&& __obj)
455 size_type __old_size = _Base::bucket_count();
456 iterator __res = _Base::insert(std::forward<_Pair>(__obj));
457 _M_profile_resize(__old_size);
461 template<
typename _Pair,
typename =
typename
462 std::enable_if<std::is_constructible<value_type,
463 _Pair&&>::value>::type>
465 insert(const_iterator __iter, _Pair&& __v)
467 size_type __old_size = _Base::bucket_count();
468 iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
469 _M_profile_resize(__old_size);
473 template<
typename _InputIter>
475 insert(_InputIter __first, _InputIter __last)
477 size_type __old_size = _Base::bucket_count();
478 _Base::insert(__first, __last);
479 _M_profile_resize(__old_size);
484 noexcept( noexcept(__x._M_base().swap(__x)) )
488 rehash(size_type __n)
490 size_type __old_size = _Base::bucket_count();
492 _M_profile_resize(__old_size);
497 _M_profile_resize(size_type __old_size)
499 size_type __new_size = _Base::bucket_count();
500 if (__old_size != __new_size)
501 __profcxx_hashtable_resize(
this, __old_size, __new_size);
505 template<
typename _Key,
typename _Tp,
typename _Hash,
506 typename _Pred,
typename _Alloc>
512 template<
typename _Key,
typename _Tp,
typename _Hash,
513 typename _Pred,
typename _Alloc>
517 {
return static_cast<const _GLIBCXX_STD_BASE&
>(__x) == __y; }
519 template<
typename _Key,
typename _Tp,
typename _Hash,
520 typename _Pred,
typename _Alloc>
522 operator!=(
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
523 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
524 {
return !(__x == __y); }
530 #undef _GLIBCXX_STD_BASE
Class std::unordered_multimap wrapper with performance instrumentation.
A standard container composed of equivalent keys (possibly containing multiple of each key value) tha...
constexpr size_t size() const noexcept
Returns the total number of bits.
Struct holding two objects of arbitrary type.
Class std::unordered_map wrapper with performance instrumentation.
A standard container composed of unique keys (containing at most one of each key value) that associat...
The standard allocator, as per [20.4].
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.
One of the comparison functors.
Sequential helper functions. This file is a GNU profile extension to the Standard C++ Library...
Primary class template hash.