29#ifndef _GLIBCXX_DEBUG_UNORDERED_MAP
30#define _GLIBCXX_DEBUG_UNORDERED_MAP 1
33#pragma GCC system_header
36#if __cplusplus < 201103L
40namespace std _GLIBCXX_VISIBILITY(default) {
namespace __debug {
41 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Pred,
44 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Pred,
56namespace std _GLIBCXX_VISIBILITY(default)
61 template<
typename _Key,
typename _Tp,
62 typename _Hash = std::hash<_Key>,
63 typename _Pred = std::equal_to<_Key>,
64 typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
67 unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>, _Alloc,
68 __gnu_debug::_Safe_unordered_container>,
69 public _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>
71 typedef _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash,
75 typedef typename _Base::const_iterator _Base_const_iterator;
76 typedef typename _Base::iterator _Base_iterator;
77 typedef typename _Base::const_local_iterator
78 _Base_const_local_iterator;
79 typedef typename _Base::local_iterator _Base_local_iterator;
81 template<
typename _ItT,
typename _SeqT,
typename _CatT>
82 friend class ::__gnu_debug::_Safe_iterator;
83 template<
typename _ItT,
typename _SeqT>
84 friend class ::__gnu_debug::_Safe_local_iterator;
89 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
95 typedef typename _Base::size_type size_type;
96 typedef typename _Base::hasher hasher;
97 typedef typename _Base::key_equal key_equal;
98 typedef typename _Base::allocator_type allocator_type;
100 typedef typename _Base::key_type key_type;
101 typedef typename _Base::value_type value_type;
102 typedef typename _Base::mapped_type mapped_type;
104 typedef typename _Base::pointer pointer;
105 typedef typename _Base::const_pointer const_pointer;
106 typedef typename _Base::reference reference;
107 typedef typename _Base::const_reference const_reference;
109 _Base_iterator, unordered_map> iterator;
111 _Base_const_iterator, unordered_map> const_iterator;
113 _Base_local_iterator, unordered_map> local_iterator;
115 _Base_const_local_iterator, unordered_map> const_local_iterator;
116 typedef typename _Base::difference_type difference_type;
118 unordered_map() =
default;
121 unordered_map(size_type __n,
122 const hasher& __hf = hasher(),
123 const key_equal& __eql = key_equal(),
124 const allocator_type& __a = allocator_type())
125 : _Base(__n, __hf, __eql, __a) { }
127 template<
typename _InputIterator>
128 unordered_map(_InputIterator __first, _InputIterator __last,
130 const hasher& __hf = hasher(),
131 const key_equal& __eql = key_equal(),
132 const allocator_type& __a = allocator_type())
134 __glibcxx_check_valid_constructor_range(__first, __last)),
136 __hf, __eql, __a) { }
138 unordered_map(
const unordered_map&) =
default;
140 unordered_map(_Base_ref __x)
141 : _Base(__x._M_ref) { }
143 unordered_map(unordered_map&&) =
default;
146 unordered_map(
const allocator_type& __a)
149 unordered_map(
const unordered_map& __umap,
150 const allocator_type& __a)
151 : _Base(__umap, __a) { }
153 unordered_map(unordered_map&& __umap,
154 const allocator_type& __a)
155 noexcept(
noexcept(_Base(
std::move(__umap), __a)) )
161 const hasher& __hf = hasher(),
162 const key_equal& __eql = key_equal(),
163 const allocator_type& __a = allocator_type())
164 : _Base(__l, __n, __hf, __eql, __a) { }
166 unordered_map(size_type __n,
const allocator_type& __a)
167 : unordered_map(__n, hasher(), key_equal(), __a)
170 unordered_map(size_type __n,
172 const allocator_type& __a)
173 : unordered_map(__n, __hf, key_equal(), __a)
176 template<
typename _InputIterator>
177 unordered_map(_InputIterator __first, _InputIterator __last,
178 const allocator_type& __a)
179 : unordered_map(__first, __last, 0, hasher(), key_equal(), __a)
182 template<
typename _InputIterator>
183 unordered_map(_InputIterator __first, _InputIterator __last,
185 const allocator_type& __a)
186 : unordered_map(__first, __last, __n, hasher(), key_equal(), __a)
189 template<
typename _InputIterator>
190 unordered_map(_InputIterator __first, _InputIterator __last,
193 const allocator_type& __a)
194 : unordered_map(__first, __last, __n, __hf, key_equal(), __a)
198 const allocator_type& __a)
199 : unordered_map(__l, 0, hasher(), key_equal(), __a)
204 const allocator_type& __a)
205 : unordered_map(__l, __n, hasher(), key_equal(), __a)
211 const allocator_type& __a)
212 : unordered_map(__l, __n, __hf, key_equal(), __a)
215#if __glibcxx_containers_ranges
216 template<__detail::__container_compatible_range<value_type> _Rg>
217 unordered_map(from_range_t, _Rg&& __rg,
219 const hasher& __hf = hasher(),
220 const key_equal& __eql = key_equal(),
221 const allocator_type& __a = allocator_type())
225 template<__detail::__container_compatible_range<value_type> _Rg>
226 unordered_map(from_range_t, _Rg&& __rg,
const allocator_type& __a)
230 template<__detail::__container_compatible_range<value_type> _Rg>
231 unordered_map(from_range_t, _Rg&& __rg, size_type __n,
232 const allocator_type& __a)
236 template<__detail::__container_compatible_range<value_type> _Rg>
237 unordered_map(from_range_t, _Rg&& __rg, size_type __n,
238 const hasher& __hf,
const allocator_type& __a)
243 ~unordered_map() =
default;
246 operator=(
const unordered_map&) =
default;
249 operator=(unordered_map&&) =
default;
254 _Base::operator=(__l);
255 this->_M_invalidate_all();
259 using _Base::get_allocator;
262 using _Base::max_size;
265 swap(unordered_map& __x)
276 this->_M_invalidate_all();
281 {
return { _Base::begin(),
this }; }
284 begin()
const noexcept
285 {
return { _Base::begin(),
this }; }
289 {
return { _Base::end(),
this }; }
293 {
return { _Base::end(),
this }; }
296 cbegin()
const noexcept
297 {
return { _Base::cbegin(),
this }; }
300 cend()
const noexcept
301 {
return { _Base::cend(),
this }; }
307 __glibcxx_check_bucket_index(__b);
308 return { _Base::begin(__b),
this };
314 __glibcxx_check_bucket_index(__b);
315 return { _Base::end(__b),
this };
319 begin(size_type __b)
const
321 __glibcxx_check_bucket_index(__b);
322 return { _Base::begin(__b),
this };
326 end(size_type __b)
const
328 __glibcxx_check_bucket_index(__b);
329 return { _Base::end(__b),
this };
333 cbegin(size_type __b)
const
335 __glibcxx_check_bucket_index(__b);
336 return { _Base::cbegin(__b),
this };
340 cend(size_type __b)
const
342 __glibcxx_check_bucket_index(__b);
343 return { _Base::cend(__b),
this };
346 using _Base::bucket_count;
347 using _Base::max_bucket_count;
351 bucket_size(size_type __b)
const
353 __glibcxx_check_bucket_index(__b);
354 return _Base::bucket_size(__b);
357 using _Base::load_factor;
360 max_load_factor()
const noexcept
361 {
return _Base::max_load_factor(); }
364 max_load_factor(
float __f)
366 __glibcxx_check_max_load_factor(__f);
367 _Base::max_load_factor(__f);
370 template<
typename... _Args>
372 emplace(_Args&&... __args)
374 size_type __bucket_count = this->bucket_count();
376 _M_check_rehashed(__bucket_count);
377 return { { __res.first,
this }, __res.second };
380 template<
typename... _Args>
382 emplace_hint(const_iterator __hint, _Args&&... __args)
385 size_type __bucket_count = this->bucket_count();
386 auto __it = _Base::emplace_hint(__hint.
base(),
388 _M_check_rehashed(__bucket_count);
389 return { __it,
this };
393 insert(
const value_type& __obj)
395 size_type __bucket_count = this->bucket_count();
396 auto __res = _Base::insert(__obj);
397 _M_check_rehashed(__bucket_count);
398 return { { __res.first,
this }, __res.second };
404 insert(value_type&& __x)
406 size_type __bucket_count = this->bucket_count();
407 auto __res = _Base::insert(
std::move(__x));
408 _M_check_rehashed(__bucket_count);
409 return { { __res.first,
this }, __res.second };
412 template<
typename _Pair,
typename =
typename
416 insert(_Pair&& __obj)
418 size_type __bucket_count = this->bucket_count();
420 _M_check_rehashed(__bucket_count);
421 return { { __res.first,
this }, __res.second };
425 insert(const_iterator __hint,
const value_type& __obj)
428 size_type __bucket_count = this->bucket_count();
429 auto __it = _Base::insert(__hint.
base(), __obj);
430 _M_check_rehashed(__bucket_count);
431 return { __it,
this };
437 insert(const_iterator __hint, value_type&& __x)
440 size_type __bucket_count = this->bucket_count();
442 _M_check_rehashed(__bucket_count);
443 return { __it,
this };
446 template<
typename _Pair,
typename =
typename
450 insert(const_iterator __hint, _Pair&& __obj)
453 size_type __bucket_count = this->bucket_count();
455 _M_check_rehashed(__bucket_count);
456 return { __it,
this };
462 size_type __bucket_count = this->bucket_count();
464 _M_check_rehashed(__bucket_count);
467 template<
typename _InputIterator>
469 insert(_InputIterator __first, _InputIterator __last)
471 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
472 __glibcxx_check_valid_range2(__first, __last, __dist);
473 size_type __bucket_count = this->bucket_count();
475 if (__dist.second >= __gnu_debug::__dp_sign)
476 _Base::insert(__gnu_debug::__unsafe(__first),
477 __gnu_debug::__unsafe(__last));
479 _Base::insert(__first, __last);
481 _M_check_rehashed(__bucket_count);
484#ifdef __glibcxx_unordered_map_try_emplace
485 template <
typename... _Args>
487 try_emplace(
const key_type& __k, _Args&&... __args)
489 auto __res = _Base::try_emplace(__k,
491 return { { __res.first,
this }, __res.second };
494 template <
typename... _Args>
496 try_emplace(key_type&& __k, _Args&&... __args)
498 auto __res = _Base::try_emplace(
std::move(__k),
500 return { { __res.first,
this }, __res.second };
503 template <
typename... _Args>
505 try_emplace(const_iterator __hint,
const key_type& __k,
509 return { _Base::try_emplace(__hint.
base(), __k,
514 template <
typename... _Args>
516 try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args)
524 template <
typename _Obj>
526 insert_or_assign(
const key_type& __k, _Obj&& __obj)
528 auto __res = _Base::insert_or_assign(__k,
530 return { { __res.first,
this }, __res.second };
533 template <
typename _Obj>
535 insert_or_assign(key_type&& __k, _Obj&& __obj)
537 auto __res = _Base::insert_or_assign(
std::move(__k),
539 return { { __res.first,
this }, __res.second };
542 template <
typename _Obj>
544 insert_or_assign(const_iterator __hint,
const key_type& __k,
548 return { _Base::insert_or_assign(__hint.
base(), __k,
553 template <
typename _Obj>
555 insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj)
558 return { _Base::insert_or_assign(__hint.
base(),
std::move(__k),
564#ifdef __glibcxx_node_extract
565 using node_type =
typename _Base::node_type;
566 using insert_return_type = _Node_insert_return<iterator, node_type>;
569 extract(const_iterator __position)
572 return _M_extract(__position.
base());
576 extract(
const key_type& __key)
578 const auto __position = _Base::find(__key);
579 if (__position != _Base::end())
580 return _M_extract(__position);
584# ifdef __glibcxx_associative_heterogeneous_erasure
585 template <__heterogeneous_hash_key<unordered_map> _Kt>
589 const auto __position = _Base::find(__key);
590 if (__position != _Base::end())
591 return _M_extract(__position);
597 insert(node_type&& __nh)
599 auto __ret = _Base::insert(
std::move(__nh));
601 { { __ret.position,
this }, __ret.inserted,
std::move(__ret.node) };
605 insert(const_iterator __hint, node_type&& __nh)
608 return { _Base::insert(__hint.
base(),
std::move(__nh)),
this };
611 template<
typename _H2,
typename _P2>
613 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source)
616 = _Safe::_S_uc_guard(std::__detail::_Select1st{}, __source);
617 _Base::merge(__source);
620 template<
typename _H2,
typename _P2>
622 merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
625 template<
typename _H2,
typename _P2>
630 = _Safe::_S_umc_guard(std::__detail::_Select1st{}, __source);
631 _Base::merge(__source);
634 template<
typename _H2,
typename _P2>
640 using _Base::hash_function;
644 find(
const key_type& __key)
645 {
return { _Base::find(__key),
this }; }
647#ifdef __glibcxx_generic_unordered_lookup
648 template<
typename _Kt,
649 typename = std::__has_is_transparent_t<_Hash, _Kt>,
650 typename = std::__has_is_transparent_t<_Pred, _Kt>>
653 {
return { _Base::find(__k),
this }; }
657 find(
const key_type& __key)
const
658 {
return { _Base::find(__key),
this }; }
660#ifdef __glibcxx_generic_unordered_lookup
661 template<
typename _Kt,
662 typename = std::__has_is_transparent_t<_Hash, _Kt>,
663 typename = std::__has_is_transparent_t<_Pred, _Kt>>
665 find(
const _Kt& __k)
const
666 {
return { _Base::find(__k),
this }; }
670#if __cplusplus > 201703L
671 using _Base::contains;
675 equal_range(
const key_type& __key)
677 auto __res = _Base::equal_range(__key);
678 return { { __res.first,
this }, { __res.second,
this } };
681#ifdef __glibcxx_generic_unordered_lookup
682 template<
typename _Kt,
683 typename = std::__has_is_transparent_t<_Hash, _Kt>,
684 typename = std::__has_is_transparent_t<_Pred, _Kt>>
686 equal_range(
const _Kt& __k)
688 auto __res = _Base::equal_range(__k);
689 return { { __res.first,
this }, { __res.second,
this } };
694 equal_range(
const key_type& __key)
const
696 auto __res = _Base::equal_range(__key);
697 return { { __res.first,
this }, { __res.second,
this } };
700#ifdef __glibcxx_generic_unordered_lookup
701 template<
typename _Kt,
702 typename = std::__has_is_transparent_t<_Hash, _Kt>,
703 typename = std::__has_is_transparent_t<_Pred, _Kt>>
705 equal_range(
const _Kt& __k)
const
707 auto __res = _Base::equal_range(__k);
708 return { { __res.first,
this }, { __res.second,
this } };
712 using _Base::operator[];
716 erase(
const key_type& __key)
719 auto __victim = _Base::find(__key);
720 if (__victim != _Base::end())
728# ifdef __glibcxx_associative_heterogeneous_erasure
729 template <__heterogeneous_hash_key<unordered_map> _Kt>
733 auto __victim = _Base::find(__key);
734 if (__victim != _Base::end())
735 return _M_erase(__victim), 1;
741 erase(const_iterator __it)
744 return { _M_erase(__it.
base()),
this };
748 erase(_Base_const_iterator __it)
750 __glibcxx_check_erase2(__it);
751 return _M_erase(__it);
758 return { _M_erase(__it.
base()),
this };
762 erase(const_iterator __first, const_iterator __last)
767 for (
auto __tmp = __first.base(); __tmp != __last.
base(); ++__tmp)
769 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(),
770 _M_message(__gnu_debug::__msg_valid_range)
771 ._M_iterator(__first,
"first")
772 ._M_iterator(__last,
"last"));
773 this->_M_invalidate(__tmp, sentry);
777 auto __next = _Base::erase(__first.base(), __last.
base());
778 return { __next,
this };
782 using _Base::reserve;
785 _M_base()
noexcept {
return *
this; }
788 _M_base()
const noexcept {
return *
this; }
792 _M_self()
const noexcept
796 _M_check_rehashed(size_type __prev_count)
798 if (__prev_count != this->bucket_count())
799 this->_M_invalidate_all();
803 _M_erase(_Base_const_iterator __victim)
805 this->_M_invalidate(__victim);
806 return _Base::erase(__victim);
809#ifdef __glibcxx_node_extract
811 _M_extract(_Base_const_iterator __victim)
813 this->_M_invalidate(__victim);
814 return _Base::extract(__victim);
819#if __cpp_deduction_guides >= 201606
821 template<
typename _InputIterator,
825 typename = _RequireInputIter<_InputIterator>,
826 typename = _RequireNotAllocatorOrIntegral<_Hash>,
827 typename = _RequireNotAllocator<_Pred>,
828 typename = _RequireAllocator<_Allocator>>
830 typename unordered_map<int, int>::size_type = {},
831 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
833 __iter_val_t<_InputIterator>,
834 _Hash, _Pred, _Allocator>;
836 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
837 typename _Pred = equal_to<_Key>,
838 typename _Allocator = allocator<pair<const _Key, _Tp>>,
839 typename = _RequireNotAllocatorOrIntegral<_Hash>,
840 typename = _RequireNotAllocator<_Pred>,
841 typename = _RequireAllocator<_Allocator>>
844 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
845 -> unordered_map<_Key, _Tp, _Hash, _Pred, _Allocator>;
847 template<
typename _InputIterator,
typename _Allocator,
848 typename = _RequireInputIter<_InputIterator>,
849 typename = _RequireAllocator<_Allocator>>
850 unordered_map(_InputIterator, _InputIterator,
851 typename unordered_map<int, int>::size_type, _Allocator)
852 -> unordered_map<__iter_key_t<_InputIterator>,
853 __iter_val_t<_InputIterator>,
854 hash<__iter_key_t<_InputIterator>>,
855 equal_to<__iter_key_t<_InputIterator>>,
858 template<
typename _InputIterator,
typename _Allocator,
859 typename = _RequireInputIter<_InputIterator>,
860 typename = _RequireAllocator<_Allocator>>
861 unordered_map(_InputIterator, _InputIterator, _Allocator)
862 -> unordered_map<__iter_key_t<_InputIterator>,
863 __iter_val_t<_InputIterator>,
864 hash<__iter_key_t<_InputIterator>>,
865 equal_to<__iter_key_t<_InputIterator>>,
868 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
869 typename = _RequireInputIter<_InputIterator>,
870 typename = _RequireNotAllocatorOrIntegral<_Hash>,
871 typename = _RequireAllocator<_Allocator>>
872 unordered_map(_InputIterator, _InputIterator,
873 typename unordered_map<int, int>::size_type,
875 -> unordered_map<__iter_key_t<_InputIterator>,
876 __iter_val_t<_InputIterator>, _Hash,
877 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
879 template<
typename _Key,
typename _Tp,
typename _Allocator,
880 typename = _RequireAllocator<_Allocator>>
882 typename unordered_map<int, int>::size_type,
884 -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
886 template<
typename _Key,
typename _Tp,
typename _Allocator,
887 typename = _RequireAllocator<_Allocator>>
889 -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
891 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
892 typename = _RequireNotAllocatorOrIntegral<_Hash>,
893 typename = _RequireAllocator<_Allocator>>
895 typename unordered_map<int, int>::size_type,
897 -> unordered_map<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>;
899#if __glibcxx_containers_ranges
900 template<ranges::input_range _Rg,
901 __not_allocator_like _Hash = hash<__detail::__range_key_type<_Rg>>,
902 __not_allocator_like _Pred = equal_to<__detail::__range_key_type<_Rg>>,
903 __allocator_like _Allocator =
904 allocator<__detail::__range_to_alloc_type<_Rg>>>
905 unordered_map(from_range_t, _Rg&&, unordered_map<int, int>::size_type = {},
906 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
908 __detail::__range_mapped_type<_Rg>,
909 _Hash, _Pred, _Allocator>;
911 template<ranges::input_range _Rg,
912 __allocator_like _Allocator>
913 unordered_map(from_range_t, _Rg&&, unordered_map<int, int>::size_type,
916 __detail::__range_mapped_type<_Rg>,
917 hash<__detail::__range_key_type<_Rg>>,
918 equal_to<__detail::__range_key_type<_Rg>>,
921 template<ranges::input_range _Rg,
922 __allocator_like _Allocator>
925 __detail::__range_mapped_type<_Rg>,
926 hash<__detail::__range_key_type<_Rg>>,
927 equal_to<__detail::__range_key_type<_Rg>>,
930 template<ranges::input_range _Rg,
931 __not_allocator_like _Hash,
932 __allocator_like _Allocator>
933 unordered_map(from_range_t, _Rg&&, unordered_map<int, int>::size_type,
936 __detail::__range_mapped_type<_Rg>,
937 _Hash, equal_to<__detail::__range_key_type<_Rg>>,
942 template<
typename _Key,
typename _Tp,
typename _Hash,
943 typename _Pred,
typename _Alloc>
947 noexcept(
noexcept(__x.swap(__y)))
950 template<
typename _Key,
typename _Tp,
typename _Hash,
951 typename _Pred,
typename _Alloc>
955 {
return __x._M_base() == __y._M_base(); }
957#if __cpp_impl_three_way_comparison < 201907L
958 template<
typename _Key,
typename _Tp,
typename _Hash,
959 typename _Pred,
typename _Alloc>
963 {
return !(__x == __y); }
967 template<
typename _Key,
typename _Tp,
968 typename _Hash = std::hash<_Key>,
969 typename _Pred = std::equal_to<_Key>,
970 typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
971 class unordered_multimap
973 unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>, _Alloc,
974 __gnu_debug::_Safe_unordered_container>,
975 public _GLIBCXX_STD_C::unordered_multimap<
976 _Key, _Tp, _Hash, _Pred, _Alloc>
978 typedef _GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash,
979 _Pred, _Alloc> _Base;
982 typedef typename _Base::const_iterator _Base_const_iterator;
983 typedef typename _Base::iterator _Base_iterator;
984 typedef typename _Base::const_local_iterator _Base_const_local_iterator;
985 typedef typename _Base::local_iterator _Base_local_iterator;
987 template<
typename _ItT,
typename _SeqT,
typename _CatT>
988 friend class ::__gnu_debug::_Safe_iterator;
989 template<
typename _ItT,
typename _SeqT>
990 friend class ::__gnu_debug::_Safe_local_iterator;
995 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
1001 typedef typename _Base::size_type size_type;
1002 typedef typename _Base::hasher hasher;
1003 typedef typename _Base::key_equal key_equal;
1004 typedef typename _Base::allocator_type allocator_type;
1006 typedef typename _Base::key_type key_type;
1007 typedef typename _Base::value_type value_type;
1008 typedef typename _Base::mapped_type mapped_type;
1010 typedef typename _Base::pointer pointer;
1011 typedef typename _Base::const_pointer const_pointer;
1012 typedef typename _Base::reference reference;
1013 typedef typename _Base::const_reference const_reference;
1015 _Base_iterator, unordered_multimap> iterator;
1017 _Base_const_iterator, unordered_multimap> const_iterator;
1019 _Base_local_iterator, unordered_multimap> local_iterator;
1021 _Base_const_local_iterator, unordered_multimap> const_local_iterator;
1022 typedef typename _Base::difference_type difference_type;
1024 unordered_multimap() =
default;
1027 unordered_multimap(size_type __n,
1028 const hasher& __hf = hasher(),
1029 const key_equal& __eql = key_equal(),
1030 const allocator_type& __a = allocator_type())
1031 : _Base(__n, __hf, __eql, __a) { }
1033 template<
typename _InputIterator>
1034 unordered_multimap(_InputIterator __first, _InputIterator __last,
1036 const hasher& __hf = hasher(),
1037 const key_equal& __eql = key_equal(),
1038 const allocator_type& __a = allocator_type())
1040 __glibcxx_check_valid_constructor_range(__first, __last)),
1042 __hf, __eql, __a) { }
1044 unordered_multimap(
const unordered_multimap&) =
default;
1046 unordered_multimap(_Base_ref __x)
1047 : _Base(__x._M_ref) { }
1049 unordered_multimap(unordered_multimap&&) =
default;
1052 unordered_multimap(
const allocator_type& __a)
1055 unordered_multimap(
const unordered_multimap& __umap,
1056 const allocator_type& __a)
1057 : _Base(__umap, __a) { }
1059 unordered_multimap(unordered_multimap&& __umap,
1060 const allocator_type& __a)
1061 noexcept(
noexcept(_Base(
std::move(__umap), __a)) )
1067 const hasher& __hf = hasher(),
1068 const key_equal& __eql = key_equal(),
1069 const allocator_type& __a = allocator_type())
1070 : _Base(__l, __n, __hf, __eql, __a) { }
1072 unordered_multimap(size_type __n,
const allocator_type& __a)
1073 : unordered_multimap(__n, hasher(), key_equal(), __a)
1076 unordered_multimap(size_type __n,
const hasher& __hf,
1077 const allocator_type& __a)
1078 : unordered_multimap(__n, __hf, key_equal(), __a)
1081 template<
typename _InputIterator>
1082 unordered_multimap(_InputIterator __first, _InputIterator __last,
1083 const allocator_type& __a)
1084 : unordered_multimap(__first, __last, 0, hasher(), key_equal(), __a)
1087 template<
typename _InputIterator>
1088 unordered_multimap(_InputIterator __first, _InputIterator __last,
1090 const allocator_type& __a)
1091 : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a)
1094 template<
typename _InputIterator>
1095 unordered_multimap(_InputIterator __first, _InputIterator __last,
1096 size_type __n,
const hasher& __hf,
1097 const allocator_type& __a)
1098 : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a)
1102 const allocator_type& __a)
1103 : unordered_multimap(__l, 0, hasher(), key_equal(), __a)
1108 const allocator_type& __a)
1109 : unordered_multimap(__l, __n, hasher(), key_equal(), __a)
1113 size_type __n,
const hasher& __hf,
1114 const allocator_type& __a)
1115 : unordered_multimap(__l, __n, __hf, key_equal(), __a)
1118#if __glibcxx_containers_ranges
1119 template<__detail::__container_compatible_range<value_type> _Rg>
1120 unordered_multimap(from_range_t, _Rg&& __rg,
1122 const hasher& __hf = hasher(),
1123 const key_equal& __eql = key_equal(),
1124 const allocator_type& __a = allocator_type())
1128 template<__detail::__container_compatible_range<value_type> _Rg>
1129 unordered_multimap(from_range_t, _Rg&& __rg,
const allocator_type& __a)
1133 template<__detail::__container_compatible_range<value_type> _Rg>
1134 unordered_multimap(from_range_t, _Rg&& __rg, size_type __n,
1135 const allocator_type& __a)
1139 template<__detail::__container_compatible_range<value_type> _Rg>
1140 unordered_multimap(from_range_t, _Rg&& __rg, size_type __n,
1141 const hasher& __hf,
const allocator_type& __a)
1146 ~unordered_multimap() =
default;
1149 operator=(
const unordered_multimap&) =
default;
1152 operator=(unordered_multimap&&) =
default;
1157 _Base::operator=(__l);
1158 this->_M_invalidate_all();
1162 using _Base::get_allocator;
1165 using _Base::max_size;
1168 swap(unordered_multimap& __x)
1171 _Safe::_M_swap(__x);
1179 this->_M_invalidate_all();
1184 {
return { _Base::begin(),
this }; }
1187 begin()
const noexcept
1188 {
return { _Base::begin(),
this }; }
1192 {
return { _Base::end(),
this }; }
1195 end()
const noexcept
1196 {
return { _Base::end(),
this }; }
1199 cbegin()
const noexcept
1200 {
return { _Base::cbegin(),
this }; }
1203 cend()
const noexcept
1204 {
return { _Base::cend(),
this }; }
1208 begin(size_type __b)
1210 __glibcxx_check_bucket_index(__b);
1211 return { _Base::begin(__b),
this };
1217 __glibcxx_check_bucket_index(__b);
1218 return { _Base::end(__b),
this };
1221 const_local_iterator
1222 begin(size_type __b)
const
1224 __glibcxx_check_bucket_index(__b);
1225 return { _Base::begin(__b),
this };
1228 const_local_iterator
1229 end(size_type __b)
const
1231 __glibcxx_check_bucket_index(__b);
1232 return { _Base::end(__b),
this };
1235 const_local_iterator
1236 cbegin(size_type __b)
const
1238 __glibcxx_check_bucket_index(__b);
1239 return { _Base::cbegin(__b),
this };
1242 const_local_iterator
1243 cend(size_type __b)
const
1245 __glibcxx_check_bucket_index(__b);
1246 return { _Base::cend(__b),
this };
1249 using _Base::bucket_count;
1250 using _Base::max_bucket_count;
1251 using _Base::bucket;
1254 bucket_size(size_type __b)
const
1256 __glibcxx_check_bucket_index(__b);
1257 return _Base::bucket_size(__b);
1261 max_load_factor()
const noexcept
1262 {
return _Base::max_load_factor(); }
1265 max_load_factor(
float __f)
1267 __glibcxx_check_max_load_factor(__f);
1268 _Base::max_load_factor(__f);
1271 template<
typename... _Args>
1273 emplace(_Args&&... __args)
1275 size_type __bucket_count = this->bucket_count();
1277 _M_check_rehashed(__bucket_count);
1278 return { __it,
this };
1281 template<
typename... _Args>
1283 emplace_hint(const_iterator __hint, _Args&&... __args)
1286 size_type __bucket_count = this->bucket_count();
1287 auto __it = _Base::emplace_hint(__hint.
base(),
1289 _M_check_rehashed(__bucket_count);
1290 return { __it,
this };
1294 insert(
const value_type& __obj)
1296 size_type __bucket_count = this->bucket_count();
1297 auto __it = _Base::insert(__obj);
1298 _M_check_rehashed(__bucket_count);
1299 return { __it,
this };
1305 insert(value_type&& __x)
1307 size_type __bucket_count = this->bucket_count();
1308 auto __it = _Base::insert(
std::move(__x));
1309 _M_check_rehashed(__bucket_count);
1310 return { __it,
this };
1314 insert(const_iterator __hint,
const value_type& __obj)
1317 size_type __bucket_count = this->bucket_count();
1318 auto __it = _Base::insert(__hint.
base(), __obj);
1319 _M_check_rehashed(__bucket_count);
1320 return { __it,
this };
1326 insert(const_iterator __hint, value_type&& __x)
1329 size_type __bucket_count = this->bucket_count();
1331 _M_check_rehashed(__bucket_count);
1332 return { __it,
this };
1335 template<
typename _Pair,
typename =
typename
1339 insert(_Pair&& __obj)
1341 size_type __bucket_count = this->bucket_count();
1343 _M_check_rehashed(__bucket_count);
1344 return { __it,
this };
1347 template<
typename _Pair,
typename =
typename
1351 insert(const_iterator __hint, _Pair&& __obj)
1354 size_type __bucket_count = this->bucket_count();
1356 _M_check_rehashed(__bucket_count);
1357 return { __it,
this };
1362 { _Base::insert(__l); }
1364 template<
typename _InputIterator>
1366 insert(_InputIterator __first, _InputIterator __last)
1368 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
1369 __glibcxx_check_valid_range2(__first, __last, __dist);
1370 size_type __bucket_count = this->bucket_count();
1372 if (__dist.second >= __gnu_debug::__dp_sign)
1373 _Base::insert(__gnu_debug::__unsafe(__first),
1374 __gnu_debug::__unsafe(__last));
1376 _Base::insert(__first, __last);
1378 _M_check_rehashed(__bucket_count);
1381#ifdef __glibcxx_node_extract
1382 using node_type =
typename _Base::node_type;
1385 extract(const_iterator __position)
1388 return _M_extract(__position.
base());
1392 extract(
const key_type& __key)
1394 const auto __position = _Base::find(__key);
1395 if (__position != _Base::end())
1396 return _M_extract(__position);
1400# ifdef __glibcxx_associative_heterogeneous_erasure
1401 template <__heterogeneous_hash_key<unordered_multimap> _Kt>
1403 extract(_Kt&& __key)
1405 const auto __position = _Base::find(__key);
1406 if (__position != _Base::end())
1407 return _M_extract(__position);
1413 insert(node_type&& __nh)
1414 {
return { _Base::insert(
std::move(__nh)),
this }; }
1417 insert(const_iterator __hint, node_type&& __nh)
1420 return { _Base::insert(__hint.
base(),
std::move(__nh)),
this };
1423 template<
typename _H2,
typename _P2>
1425 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source)
1428 = _Safe::_S_umc_guard(std::__detail::_Select1st{}, __source);
1429 _Base::merge(__source);
1432 template<
typename _H2,
typename _P2>
1434 merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source)
1435 { merge(__source); }
1437 template<
typename _H2,
typename _P2>
1442 = _Safe::_S_uc_guard(std::__detail::_Select1st{}, __source);
1443 _Base::merge(__source);
1446 template<
typename _H2,
typename _P2>
1449 { merge(__source); }
1452 using _Base::hash_function;
1453 using _Base::key_eq;
1456 find(
const key_type& __key)
1457 {
return { _Base::find(__key),
this }; }
1459#ifdef __glibcxx_generic_unordered_lookup
1460 template<
typename _Kt,
1461 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1462 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1464 find(
const _Kt& __k)
1465 {
return { _Base::find(__k),
this }; }
1469 find(
const key_type& __key)
const
1470 {
return { _Base::find(__key),
this }; }
1472#ifdef __glibcxx_generic_unordered_lookup
1473 template<
typename _Kt,
1474 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1475 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1477 find(
const _Kt& __k)
const
1478 {
return { _Base::find(__k),
this }; }
1482#if __cplusplus > 201703L
1483 using _Base::contains;
1487 equal_range(
const key_type& __key)
1489 auto __res = _Base::equal_range(__key);
1490 return { { __res.first,
this }, { __res.second,
this } };
1493#ifdef __glibcxx_generic_unordered_lookup
1494 template<
typename _Kt,
1495 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1496 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1498 equal_range(
const _Kt& __k)
1500 auto __res = _Base::equal_range(__k);
1501 return { { __res.first,
this }, { __res.second,
this } };
1506 equal_range(
const key_type& __key)
const
1508 auto __res = _Base::equal_range(__key);
1509 return { { __res.first,
this }, { __res.second,
this } };
1512#ifdef __glibcxx_generic_unordered_lookup
1513 template<
typename _Kt,
1514 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1515 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1517 equal_range(
const _Kt& __k)
const
1519 auto __res = _Base::equal_range(__k);
1520 return { { __res.first,
this }, { __res.second,
this } };
1525 erase(
const key_type& __key)
1527 auto __victims = _Base::equal_range(__key);
1528 return _M_erase(__victims.first, __victims.second);
1531# ifdef __glibcxx_associative_heterogeneous_erasure
1532 template <__heterogeneous_hash_key<unordered_multimap> _Kt>
1536 auto __victims = _Base::equal_range(__key);
1537 return _M_erase(__victims.first, __victims.second);
1542 erase(const_iterator __it)
1545 return { _M_erase(__it.
base()),
this };
1549 erase(_Base_const_iterator __it)
1551 __glibcxx_check_erase2(__it);
1552 return _M_erase(__it);
1556 erase(iterator __it)
1559 return { _M_erase(__it.
base()),
this };
1563 erase(const_iterator __first, const_iterator __last)
1568 for (
auto __tmp = __first.base(); __tmp != __last.
base(); ++__tmp)
1570 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(),
1571 _M_message(__gnu_debug::__msg_valid_range)
1572 ._M_iterator(__first,
"first")
1573 ._M_iterator(__last,
"last"));
1574 this->_M_invalidate(__tmp, sentry);
1578 auto __next = _Base::erase(__first.base(), __last.
base());
1579 return { __next,
this };
1582 using _Base::rehash;
1583 using _Base::reserve;
1586 _M_base()
noexcept {
return *
this; }
1589 _M_base()
const noexcept {
return *
this; }
1592 const unordered_multimap*
1593 _M_self()
const noexcept
1597 _M_check_rehashed(size_type __prev_count)
1599 if (__prev_count != this->bucket_count())
1600 this->_M_invalidate_all();
1604 _M_erase(_Base_const_iterator __victim)
1606 this->_M_invalidate(__victim);
1607 return _Base::erase(__victim);
1611 _M_erase(_Base_iterator __first, _Base_iterator __last)
1616 for (
auto __victim = __first; __victim != __last; ++__victim)
1618 this->_M_invalidate(__victim, sentry);
1623 _Base::erase(__first, __last);
1627#ifdef __glibcxx_node_extract
1629 _M_extract(_Base_const_iterator __victim)
1631 this->_M_invalidate(__victim);
1632 return _Base::extract(__victim);
1637#if __cpp_deduction_guides >= 201606
1639 template<
typename _InputIterator,
1643 typename = _RequireInputIter<_InputIterator>,
1644 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1645 typename = _RequireNotAllocator<_Pred>,
1646 typename = _RequireAllocator<_Allocator>>
1648 unordered_multimap<int, int>::size_type = {},
1649 _Hash = _Hash(), _Pred = _Pred(),
1650 _Allocator = _Allocator())
1652 __iter_val_t<_InputIterator>, _Hash, _Pred,
1655 template<
typename _Key,
typename _Tp,
typename _Hash = hash<_Key>,
1656 typename _Pred = equal_to<_Key>,
1657 typename _Allocator = allocator<pair<const _Key, _Tp>>,
1658 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1659 typename = _RequireNotAllocator<_Pred>,
1660 typename = _RequireAllocator<_Allocator>>
1663 _Hash = _Hash(), _Pred = _Pred(),
1664 _Allocator = _Allocator())
1665 -> unordered_multimap<_Key, _Tp, _Hash, _Pred, _Allocator>;
1667 template<
typename _InputIterator,
typename _Allocator,
1668 typename = _RequireInputIter<_InputIterator>,
1669 typename = _RequireAllocator<_Allocator>>
1670 unordered_multimap(_InputIterator, _InputIterator,
1671 unordered_multimap<int, int>::size_type, _Allocator)
1672 -> unordered_multimap<__iter_key_t<_InputIterator>,
1673 __iter_val_t<_InputIterator>,
1674 hash<__iter_key_t<_InputIterator>>,
1675 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
1677 template<
typename _InputIterator,
typename _Allocator,
1678 typename = _RequireInputIter<_InputIterator>,
1679 typename = _RequireAllocator<_Allocator>>
1680 unordered_multimap(_InputIterator, _InputIterator, _Allocator)
1681 -> unordered_multimap<__iter_key_t<_InputIterator>,
1682 __iter_val_t<_InputIterator>,
1683 hash<__iter_key_t<_InputIterator>>,
1684 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
1686 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
1687 typename = _RequireInputIter<_InputIterator>,
1688 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1689 typename = _RequireAllocator<_Allocator>>
1690 unordered_multimap(_InputIterator, _InputIterator,
1691 unordered_multimap<int, int>::size_type, _Hash,
1693 -> unordered_multimap<__iter_key_t<_InputIterator>,
1694 __iter_val_t<_InputIterator>, _Hash,
1695 equal_to<__iter_key_t<_InputIterator>>, _Allocator>;
1697 template<
typename _Key,
typename _Tp,
typename _Allocator,
1698 typename = _RequireAllocator<_Allocator>>
1700 unordered_multimap<int, int>::size_type,
1702 -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
1704 template<
typename _Key,
typename _Tp,
typename _Allocator,
1705 typename = _RequireAllocator<_Allocator>>
1707 -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>;
1709 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _Allocator,
1710 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1711 typename = _RequireAllocator<_Allocator>>
1713 unordered_multimap<int, int>::size_type,
1715 -> unordered_multimap<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>;
1717#if __glibcxx_containers_ranges
1718 template<ranges::input_range _Rg,
1719 __not_allocator_like _Hash = hash<__detail::__range_key_type<_Rg>>,
1720 __not_allocator_like _Pred = equal_to<__detail::__range_key_type<_Rg>>,
1721 __allocator_like _Allocator =
1722 allocator<__detail::__range_to_alloc_type<_Rg>>>
1723 unordered_multimap(from_range_t, _Rg&&,
1724 unordered_multimap<int, int>::size_type = {},
1725 _Hash = _Hash(), _Pred = _Pred(),
1726 _Allocator = _Allocator())
1728 __detail::__range_mapped_type<_Rg>,
1729 _Hash, _Pred, _Allocator>;
1731 template<ranges::input_range _Rg,
1732 __allocator_like _Allocator>
1736 __detail::__range_mapped_type<_Rg>,
1737 hash<__detail::__range_key_type<_Rg>>,
1738 equal_to<__detail::__range_key_type<_Rg>>,
1741 template<ranges::input_range _Rg,
1742 __allocator_like _Allocator>
1745 __detail::__range_mapped_type<_Rg>,
1746 hash<__detail::__range_key_type<_Rg>>,
1747 equal_to<__detail::__range_key_type<_Rg>>,
1750 template<ranges::input_range _Rg,
1751 __not_allocator_like _Hash,
1752 __allocator_like _Allocator>
1754 unordered_multimap<int, int>::size_type,
1757 __detail::__range_mapped_type<_Rg>,
1758 _Hash, equal_to<__detail::__range_key_type<_Rg>>,
1763 template<
typename _Key,
typename _Tp,
typename _Hash,
1764 typename _Pred,
typename _Alloc>
1768 noexcept(
noexcept(__x.swap(__y)))
1771 template<
typename _Key,
typename _Tp,
typename _Hash,
1772 typename _Pred,
typename _Alloc>
1776 {
return __x._M_base() == __y._M_base(); }
1778#if __cpp_impl_three_way_comparison < 201907L
1779 template<
typename _Key,
typename _Tp,
typename _Hash,
1780 typename _Pred,
typename _Alloc>
1784 {
return !(__x == __y); }
1789#ifdef __glibcxx_erase_if
1790_GLIBCXX_BEGIN_NAMESPACE_VERSION
1791 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _CPred,
1792 typename _Alloc,
typename _Predicate>
1794 _CPred, _Alloc>::size_type
1797 {
return __detail::__erase_nodes_if(__cont, __cont._M_base(), __pred); }
1799 template<
typename _Key,
typename _Tp,
typename _Hash,
typename _CPred,
1800 typename _Alloc,
typename _Predicate>
1802 _CPred, _Alloc>::size_type
1805 {
return __detail::__erase_nodes_if(__cont, __cont._M_base(), __pred); }
1806_GLIBCXX_END_NAMESPACE_VERSION
#define __glibcxx_check_insert(_Position)
#define __glibcxx_check_erase_range(_First, _Last)
#define __glibcxx_check_erase(_Position)
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs are equal iff their members are equal.
auto declval() noexcept -> decltype(__declval< _Tp >(0))
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
constexpr _Iterator __base(_Iterator __it)
GNU debug code, replaces standard behavior with debug behavior.
Primary class template hash.
Define a member typedef type only if a boolean constant is true.
The standard allocator, as per C++03 [20.4.1].
constexpr _Iterator & base() noexcept
Return the underlying iterator.
One of the comparison functors.
Struct holding two objects of arbitrary type.
A standard container composed of equivalent keys (possibly containing multiple of each key value) tha...
_Hashtable::size_type size_type
Iterator-related typedefs.
A standard container composed of unique keys (containing at most one of each key value) that associat...
_Hashtable::size_type size_type
Iterator-related typedefs.
Safe class dealing with some allocator dependent operations.
Base class for constructing a safe unordered container type that tracks iterators that reference it.
Class std::unordered_map with safety/checking/debug instrumentation.
Class std::unordered_multimap with safety/checking/debug instrumentation.