29#ifndef _GLIBCXX_DEBUG_UNORDERED_SET
30#define _GLIBCXX_DEBUG_UNORDERED_SET 1
33#pragma GCC system_header
36#if __cplusplus < 201103L
40namespace std _GLIBCXX_VISIBILITY(default) {
namespace __debug {
41 template<
typename _Key,
typename _Hash,
typename _Pred,
typename _Allocator>
43 template<
typename _Key,
typename _Hash,
typename _Pred,
typename _Allocator>
53namespace std _GLIBCXX_VISIBILITY(default)
58 template<
typename _Value,
59 typename _Hash = std::hash<_Value>,
60 typename _Pred = std::equal_to<_Value>,
61 typename _Alloc = std::allocator<_Value> >
64 unordered_set<_Value, _Hash, _Pred, _Alloc>, _Alloc,
65 __gnu_debug::_Safe_unordered_container>,
66 public _GLIBCXX_STD_C::unordered_set<_Value, _Hash, _Pred, _Alloc>
68 typedef _GLIBCXX_STD_C::unordered_set<
69 _Value, _Hash, _Pred, _Alloc> _Base;
73 typedef typename _Base::const_iterator _Base_const_iterator;
74 typedef typename _Base::iterator _Base_iterator;
75 typedef typename _Base::const_local_iterator _Base_const_local_iterator;
76 typedef typename _Base::local_iterator _Base_local_iterator;
78 template<
typename _ItT,
typename _SeqT,
typename _CatT>
79 friend class ::__gnu_debug::_Safe_iterator;
80 template<
typename _ItT,
typename _SeqT>
81 friend class ::__gnu_debug::_Safe_local_iterator;
86 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
92 typedef typename _Base::size_type size_type;
93 typedef typename _Base::difference_type difference_type;
94 typedef typename _Base::hasher hasher;
95 typedef typename _Base::key_equal key_equal;
96 typedef typename _Base::allocator_type allocator_type;
98 typedef typename _Base::key_type key_type;
99 typedef typename _Base::value_type value_type;
101 typedef typename _Base::pointer pointer;
102 typedef typename _Base::const_pointer const_pointer;
103 typedef typename _Base::reference reference;
104 typedef typename _Base::const_reference const_reference;
106 _Base_iterator, unordered_set> iterator;
108 _Base_const_iterator, unordered_set> const_iterator;
110 _Base_local_iterator, unordered_set> local_iterator;
112 _Base_const_local_iterator, unordered_set> const_local_iterator;
114 unordered_set() =
default;
117 unordered_set(size_type __n,
118 const hasher& __hf = hasher(),
119 const key_equal& __eql = key_equal(),
120 const allocator_type& __a = allocator_type())
121 : _Base(__n, __hf, __eql, __a) { }
123 template<
typename _InputIterator>
124 unordered_set(_InputIterator __first, _InputIterator __last,
126 const hasher& __hf = hasher(),
127 const key_equal& __eql = key_equal(),
128 const allocator_type& __a = allocator_type())
130 __glibcxx_check_valid_constructor_range(__first, __last)),
132 __hf, __eql, __a) { }
134 unordered_set(
const unordered_set&) =
default;
136 unordered_set(_Base_ref __x)
137 : _Base(__x._M_ref) { }
139 unordered_set(unordered_set&&) =
default;
142 unordered_set(
const allocator_type& __a)
145 unordered_set(
const unordered_set& __uset,
146 const allocator_type& __a)
147 : _Base(__uset, __a) { }
149 unordered_set(unordered_set&& __uset,
150 const allocator_type& __a)
151 noexcept(
noexcept(_Base(
std::move(__uset), __a)) )
157 const hasher& __hf = hasher(),
158 const key_equal& __eql = key_equal(),
159 const allocator_type& __a = allocator_type())
160 : _Base(__l, __n, __hf, __eql, __a) { }
162 unordered_set(size_type __n,
const allocator_type& __a)
163 : unordered_set(__n, hasher(), key_equal(), __a)
166 unordered_set(size_type __n,
const hasher& __hf,
167 const allocator_type& __a)
168 : unordered_set(__n, __hf, key_equal(), __a)
171 template<
typename _InputIterator>
172 unordered_set(_InputIterator __first, _InputIterator __last,
173 const allocator_type& __a)
174 : unordered_set(__first, __last, 0, hasher(), key_equal(), __a)
177 template<
typename _InputIterator>
178 unordered_set(_InputIterator __first, _InputIterator __last,
180 const allocator_type& __a)
181 : unordered_set(__first, __last, __n, hasher(), key_equal(), __a)
184 template<
typename _InputIterator>
185 unordered_set(_InputIterator __first, _InputIterator __last,
186 size_type __n,
const hasher& __hf,
187 const allocator_type& __a)
188 : unordered_set(__first, __last, __n, __hf, key_equal(), __a)
192 const allocator_type& __a)
193 : unordered_set(__l, 0, hasher(), key_equal(), __a)
198 const allocator_type& __a)
199 : unordered_set(__l, __n, hasher(), key_equal(), __a)
203 size_type __n,
const hasher& __hf,
204 const allocator_type& __a)
205 : unordered_set(__l, __n, __hf, key_equal(), __a)
208#if __glibcxx_containers_ranges
209 template<__detail::__container_compatible_range<value_type> _Rg>
210 unordered_set(from_range_t, _Rg&& __rg,
212 const hasher& __hf = hasher(),
213 const key_equal& __eql = key_equal(),
214 const allocator_type& __a = allocator_type())
218 template<__detail::__container_compatible_range<value_type> _Rg>
219 unordered_set(from_range_t, _Rg&& __rg,
const allocator_type& __a)
223 template<__detail::__container_compatible_range<value_type> _Rg>
224 unordered_set(from_range_t, _Rg&& __rg, size_type __n,
225 const allocator_type& __a)
229 template<__detail::__container_compatible_range<value_type> _Rg>
230 unordered_set(from_range_t, _Rg&& __rg, size_type __n,
231 const hasher& __hf,
const allocator_type& __a)
236 ~unordered_set() =
default;
239 operator=(
const unordered_set&) =
default;
242 operator=(unordered_set&&) =
default;
247 _Base::operator=(__l);
248 this->_M_invalidate_all();
252 using _Base::get_allocator;
255 using _Base::max_size;
258 swap(unordered_set& __x)
269 this->_M_invalidate_all();
274 {
return { _Base::begin(),
this }; }
277 begin()
const noexcept
278 {
return { _Base::begin(),
this }; }
282 {
return { _Base::end(),
this }; }
286 {
return { _Base::end(),
this }; }
289 cbegin()
const noexcept
290 {
return { _Base::cbegin(),
this }; }
293 cend()
const noexcept
294 {
return { _Base::cend(),
this }; }
300 __glibcxx_check_bucket_index(__b);
301 return { _Base::begin(__b),
this };
307 __glibcxx_check_bucket_index(__b);
308 return { _Base::end(__b),
this };
312 begin(size_type __b)
const
314 __glibcxx_check_bucket_index(__b);
315 return { _Base::begin(__b),
this };
319 end(size_type __b)
const
321 __glibcxx_check_bucket_index(__b);
322 return { _Base::end(__b),
this };
326 cbegin(size_type __b)
const
328 __glibcxx_check_bucket_index(__b);
329 return { _Base::cbegin(__b),
this };
333 cend(size_type __b)
const
335 __glibcxx_check_bucket_index(__b);
336 return { _Base::cend(__b),
this };
339 using _Base::bucket_count;
340 using _Base::max_bucket_count;
343 bucket_size(size_type __b)
const
345 __glibcxx_check_bucket_index(__b);
346 return _Base::bucket_size(__b);
350 using _Base::load_factor;
353 max_load_factor()
const noexcept
354 {
return _Base::max_load_factor(); }
357 max_load_factor(
float __f)
359 __glibcxx_check_max_load_factor(__f);
360 _Base::max_load_factor(__f);
364 using _Base::reserve;
366 template<
typename... _Args>
368 emplace(_Args&&... __args)
370 size_type __bucket_count = this->bucket_count();
372 _M_check_rehashed(__bucket_count);
373 return { { __res.first,
this }, __res.second };
376 template<
typename... _Args>
378 emplace_hint(const_iterator __hint, _Args&&... __args)
381 size_type __bucket_count = this->bucket_count();
382 auto __it = _Base::emplace_hint(__hint.
base(),
384 _M_check_rehashed(__bucket_count);
385 return { __it,
this };
389 insert(
const value_type& __obj)
391 size_type __bucket_count = this->bucket_count();
392 auto __res = _Base::insert(__obj);
393 _M_check_rehashed(__bucket_count);
394 return { { __res.first,
this }, __res.second };
398 insert(const_iterator __hint,
const value_type& __obj)
401 size_type __bucket_count = this->bucket_count();
402 auto __it = _Base::insert(__hint.
base(), __obj);
403 _M_check_rehashed(__bucket_count);
404 return { __it,
this };
408 insert(value_type&& __obj)
410 size_type __bucket_count = this->bucket_count();
411 auto __res = _Base::insert(
std::move(__obj));
412 _M_check_rehashed(__bucket_count);
413 return { { __res.first,
this }, __res.second };
417 insert(const_iterator __hint, value_type&& __obj)
420 size_type __bucket_count = this->bucket_count();
422 _M_check_rehashed(__bucket_count);
423 return { __it,
this };
429 size_type __bucket_count = this->bucket_count();
431 _M_check_rehashed(__bucket_count);
434 template<
typename _InputIterator>
436 insert(_InputIterator __first, _InputIterator __last)
438 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
439 __glibcxx_check_valid_range2(__first, __last, __dist);
440 size_type __bucket_count = this->bucket_count();
442 if (__dist.second >= __gnu_debug::__dp_sign)
443 _Base::insert(__gnu_debug::__unsafe(__first),
444 __gnu_debug::__unsafe(__last));
446 _Base::insert(__first, __last);
448 _M_check_rehashed(__bucket_count);
451#ifdef __glibcxx_node_extract
452 using node_type =
typename _Base::node_type;
453 using insert_return_type = _Node_insert_return<iterator, node_type>;
456 extract(const_iterator __position)
459 return _M_extract(__position.
base());
463 extract(
const key_type& __key)
465 const auto __position = _Base::find(__key);
466 if (__position != _Base::end())
467 return _M_extract(__position);
471# ifdef __glibcxx_associative_heterogeneous_erasure
472 template <__heterogeneous_hash_key<unordered_set> _Kt>
476 const auto __position = _Base::find(__key);
477 if (__position != _Base::end())
478 return _M_extract(__position);
484 insert(node_type&& __nh)
486 auto __ret = _Base::insert(
std::move(__nh));
488 { { __ret.position,
this }, __ret.inserted,
std::move(__ret.node) };
492 insert(const_iterator __hint, node_type&& __nh)
495 return { _Base::insert(__hint.
base(),
std::move(__nh)),
this };
498 template<
typename _H2,
typename _P2>
500 merge(unordered_set<_Value, _H2, _P2, _Alloc>& __source)
503 = _Safe::_S_uc_guard(std::__detail::_Identity{}, __source);
504 _Base::merge(__source);
507 template<
typename _H2,
typename _P2>
509 merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source)
512 template<
typename _H2,
typename _P2>
517 = _Safe::_S_umc_guard(std::__detail::_Identity{}, __source);
518 _Base::merge(__source);
521 template<
typename _H2,
typename _P2>
527 using _Base::hash_function;
531 find(
const key_type& __key)
532 {
return { _Base::find(__key),
this }; }
534#ifdef __glibcxx_generic_unordered_lookup
535 template<
typename _Kt,
536 typename = std::__has_is_transparent_t<_Hash, _Kt>,
537 typename = std::__has_is_transparent_t<_Pred, _Kt>>
540 {
return { _Base::find(__k),
this }; }
544 find(
const key_type& __key)
const
545 {
return { _Base::find(__key),
this }; }
547#ifdef __glibcxx_generic_unordered_lookup
548 template<
typename _Kt,
549 typename = std::__has_is_transparent_t<_Hash, _Kt>,
550 typename = std::__has_is_transparent_t<_Pred, _Kt>>
552 find(
const _Kt& __k)
const
553 {
return { _Base::find(__k),
this }; }
558#if __cplusplus > 201703L
559 using _Base::contains;
563 equal_range(
const key_type& __key)
565 auto __res = _Base::equal_range(__key);
566 return { { __res.first,
this }, { __res.second,
this } };
569#ifdef __glibcxx_generic_unordered_lookup
570 template<
typename _Kt,
571 typename = std::__has_is_transparent_t<_Hash, _Kt>,
572 typename = std::__has_is_transparent_t<_Pred, _Kt>>
574 equal_range(
const _Kt& __k)
576 auto __res = _Base::equal_range(__k);
577 return { { __res.first,
this }, { __res.second,
this } };
582 equal_range(
const key_type& __key)
const
584 auto __res = _Base::equal_range(__key);
585 return { { __res.first,
this }, { __res.second,
this } };
588#ifdef __glibcxx_generic_unordered_lookup
589 template<
typename _Kt,
590 typename = std::__has_is_transparent_t<_Hash, _Kt>,
591 typename = std::__has_is_transparent_t<_Pred, _Kt>>
593 equal_range(
const _Kt& __k)
const
595 auto __res = _Base::equal_range(__k);
596 return { { __res.first,
this }, { __res.second,
this } };
601 erase(
const key_type& __key)
604 auto __victim = _Base::find(__key);
605 if (__victim != _Base::end())
613# ifdef __glibcxx_associative_heterogeneous_erasure
614 template <__heterogeneous_hash_key<unordered_set> _Kt>
618 auto __victim = _Base::find(__key);
619 if (__victim != _Base::end())
620 return _M_erase(__victim), 1;
626 erase(const_iterator __it)
629 return { _M_erase(__it.
base()),
this };
633 erase(_Base_const_iterator __it)
635 __glibcxx_check_erase2(__it);
636 return _M_erase(__it);
643 return { _M_erase(__it.
base()),
this };
647 erase(const_iterator __first, const_iterator __last)
652 for (
auto __tmp = __first.base(); __tmp != __last.
base(); ++__tmp)
654 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(),
655 _M_message(__gnu_debug::__msg_valid_range)
656 ._M_iterator(__first,
"first")
657 ._M_iterator(__last,
"last"));
658 this->_M_invalidate(__tmp, sentry);
662 auto __next = _Base::erase(__first.base(), __last.
base());
663 return { __next,
this };
667 _M_base()
noexcept {
return *
this; }
670 _M_base()
const noexcept {
return *
this; }
674 _M_self()
const noexcept
678 _M_check_rehashed(size_type __prev_count)
680 if (__prev_count != this->bucket_count())
681 this->_M_invalidate_all();
685 _M_erase(_Base_const_iterator __victim)
687 this->_M_invalidate(__victim);
688 return _Base::erase(__victim);
691#ifdef __glibcxx_node_extract
693 _M_extract(_Base_const_iterator __victim)
695 this->_M_invalidate(__victim);
696 return _Base::extract(__victim);
701#if __cpp_deduction_guides >= 201606
703 template<
typename _InputIterator,
708 typename _Allocator =
710 typename = _RequireInputIter<_InputIterator>,
711 typename = _RequireNotAllocatorOrIntegral<_Hash>,
712 typename = _RequireNotAllocator<_Pred>,
713 typename = _RequireAllocator<_Allocator>>
715 unordered_set<int>::size_type = {},
716 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
718 _Hash, _Pred, _Allocator>;
720 template<
typename _Tp,
typename _Hash = hash<_Tp>,
721 typename _Pred = equal_to<_Tp>,
722 typename _Allocator = allocator<_Tp>,
723 typename = _RequireNotAllocatorOrIntegral<_Hash>,
724 typename = _RequireNotAllocator<_Pred>,
725 typename = _RequireAllocator<_Allocator>>
728 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
729 -> unordered_set<_Tp, _Hash, _Pred, _Allocator>;
731 template<
typename _InputIterator,
typename _Allocator,
732 typename = _RequireInputIter<_InputIterator>,
733 typename = _RequireAllocator<_Allocator>>
734 unordered_set(_InputIterator, _InputIterator,
735 unordered_set<int>::size_type, _Allocator)
736 -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
738 typename iterator_traits<_InputIterator>::value_type>,
740 typename iterator_traits<_InputIterator>::value_type>,
743 template<
typename _InputIterator,
typename _Allocator,
744 typename = _RequireInputIter<_InputIterator>,
745 typename = _RequireAllocator<_Allocator>>
746 unordered_set(_InputIterator, _InputIterator, _Allocator)
747 -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
749 typename iterator_traits<_InputIterator>::value_type>,
751 typename iterator_traits<_InputIterator>::value_type>,
754 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
755 typename = _RequireInputIter<_InputIterator>,
756 typename = _RequireNotAllocatorOrIntegral<_Hash>,
757 typename = _RequireAllocator<_Allocator>>
758 unordered_set(_InputIterator, _InputIterator,
759 unordered_set<int>::size_type,
761 -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
764 typename iterator_traits<_InputIterator>::value_type>,
767 template<
typename _Tp,
typename _Allocator,
768 typename = _RequireAllocator<_Allocator>>
769 unordered_set(initializer_list<_Tp>,
770 unordered_set<int>::size_type, _Allocator)
771 -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
773 template<
typename _Tp,
typename _Allocator,
774 typename = _RequireAllocator<_Allocator>>
775 unordered_set(initializer_list<_Tp>, _Allocator)
776 -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
778 template<
typename _Tp,
typename _Hash,
typename _Allocator,
779 typename = _RequireNotAllocatorOrIntegral<_Hash>,
780 typename = _RequireAllocator<_Allocator>>
781 unordered_set(initializer_list<_Tp>,
782 unordered_set<int>::size_type, _Hash, _Allocator)
783 -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
787 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
789 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
790 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
791 noexcept(
noexcept(__x.swap(__y)))
794 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
798 {
return __x._M_base() == __y._M_base(); }
800#if __cpp_impl_three_way_comparison < 201907L
801 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
805 {
return !(__x == __y); }
809 template<
typename _Value,
810 typename _Hash = std::hash<_Value>,
811 typename _Pred = std::equal_to<_Value>,
812 typename _Alloc = std::allocator<_Value> >
813 class unordered_multiset
815 unordered_multiset<_Value, _Hash, _Pred, _Alloc>, _Alloc,
816 __gnu_debug::_Safe_unordered_container>,
817 public _GLIBCXX_STD_C::unordered_multiset<_Value, _Hash, _Pred, _Alloc>
819 typedef _GLIBCXX_STD_C::unordered_multiset<
820 _Value, _Hash, _Pred, _Alloc> _Base;
823 typedef typename _Base::const_iterator _Base_const_iterator;
824 typedef typename _Base::iterator _Base_iterator;
825 typedef typename _Base::const_local_iterator
826 _Base_const_local_iterator;
827 typedef typename _Base::local_iterator _Base_local_iterator;
829 template<
typename _ItT,
typename _SeqT,
typename _CatT>
830 friend class ::__gnu_debug::_Safe_iterator;
831 template<
typename _ItT,
typename _SeqT>
832 friend class ::__gnu_debug::_Safe_local_iterator;
837 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
843 typedef typename _Base::size_type size_type;
844 typedef typename _Base::difference_type difference_type;
845 typedef typename _Base::hasher hasher;
846 typedef typename _Base::key_equal key_equal;
847 typedef typename _Base::allocator_type allocator_type;
849 typedef typename _Base::key_type key_type;
850 typedef typename _Base::value_type value_type;
852 typedef typename _Base::pointer pointer;
853 typedef typename _Base::const_pointer const_pointer;
854 typedef typename _Base::reference reference;
855 typedef typename _Base::const_reference const_reference;
857 _Base_iterator, unordered_multiset> iterator;
859 _Base_const_iterator, unordered_multiset> const_iterator;
861 _Base_local_iterator, unordered_multiset> local_iterator;
863 _Base_const_local_iterator, unordered_multiset> const_local_iterator;
865 unordered_multiset() =
default;
868 unordered_multiset(size_type __n,
869 const hasher& __hf = hasher(),
870 const key_equal& __eql = key_equal(),
871 const allocator_type& __a = allocator_type())
872 : _Base(__n, __hf, __eql, __a) { }
874 template<
typename _InputIterator>
875 unordered_multiset(_InputIterator __first, _InputIterator __last,
877 const hasher& __hf = hasher(),
878 const key_equal& __eql = key_equal(),
879 const allocator_type& __a = allocator_type())
881 __glibcxx_check_valid_constructor_range(__first, __last)),
883 __hf, __eql, __a) { }
885 unordered_multiset(
const unordered_multiset&) =
default;
887 unordered_multiset(_Base_ref __x)
888 : _Base(__x._M_ref) { }
890 unordered_multiset(unordered_multiset&&) =
default;
893 unordered_multiset(
const allocator_type& __a)
896 unordered_multiset(
const unordered_multiset& __uset,
897 const allocator_type& __a)
898 : _Base(__uset, __a) { }
900 unordered_multiset(unordered_multiset&& __uset,
901 const allocator_type& __a)
902 noexcept(
noexcept(_Base(
std::move(__uset), __a)) )
908 const hasher& __hf = hasher(),
909 const key_equal& __eql = key_equal(),
910 const allocator_type& __a = allocator_type())
911 : _Base(__l, __n, __hf, __eql, __a) { }
913 unordered_multiset(size_type __n,
const allocator_type& __a)
914 : unordered_multiset(__n, hasher(), key_equal(), __a)
917 unordered_multiset(size_type __n,
const hasher& __hf,
918 const allocator_type& __a)
919 : unordered_multiset(__n, __hf, key_equal(), __a)
922 template<
typename _InputIterator>
923 unordered_multiset(_InputIterator __first, _InputIterator __last,
924 const allocator_type& __a)
925 : unordered_multiset(__first, __last, 0, hasher(), key_equal(), __a)
928 template<
typename _InputIterator>
929 unordered_multiset(_InputIterator __first, _InputIterator __last,
931 const allocator_type& __a)
932 : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a)
935 template<
typename _InputIterator>
936 unordered_multiset(_InputIterator __first, _InputIterator __last,
937 size_type __n,
const hasher& __hf,
938 const allocator_type& __a)
939 : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a)
943 const allocator_type& __a)
944 : unordered_multiset(__l, 0, hasher(), key_equal(), __a)
949 const allocator_type& __a)
950 : unordered_multiset(__l, __n, hasher(), key_equal(), __a)
954 size_type __n,
const hasher& __hf,
955 const allocator_type& __a)
956 : unordered_multiset(__l, __n, __hf, key_equal(), __a)
959#if __glibcxx_containers_ranges
960 template<__detail::__container_compatible_range<value_type> _Rg>
961 unordered_multiset(from_range_t, _Rg&& __rg,
963 const hasher& __hf = hasher(),
964 const key_equal& __eql = key_equal(),
965 const allocator_type& __a = allocator_type())
969 template<__detail::__container_compatible_range<value_type> _Rg>
970 unordered_multiset(from_range_t, _Rg&& __rg,
const allocator_type& __a)
974 template<__detail::__container_compatible_range<value_type> _Rg>
975 unordered_multiset(from_range_t, _Rg&& __rg, size_type __n,
976 const allocator_type& __a)
980 template<__detail::__container_compatible_range<value_type> _Rg>
981 unordered_multiset(from_range_t, _Rg&& __rg, size_type __n,
982 const hasher& __hf,
const allocator_type& __a)
987 ~unordered_multiset() =
default;
990 operator=(
const unordered_multiset&) =
default;
993 operator=(unordered_multiset&&) =
default;
998 _Base::operator=(__l);
999 this->_M_invalidate_all();
1003 using _Base::get_allocator;
1006 using _Base::max_size;
1009 swap(unordered_multiset& __x)
1012 _Safe::_M_swap(__x);
1020 this->_M_invalidate_all();
1025 {
return { _Base::begin(),
this }; }
1028 begin()
const noexcept
1029 {
return { _Base::begin(),
this }; }
1033 {
return { _Base::end(),
this }; }
1036 end()
const noexcept
1037 {
return { _Base::end(),
this }; }
1040 cbegin()
const noexcept
1041 {
return { _Base::cbegin(),
this }; }
1044 cend()
const noexcept
1045 {
return { _Base::cend(),
this }; }
1049 begin(size_type __b)
1051 __glibcxx_check_bucket_index(__b);
1052 return { _Base::begin(__b),
this };
1058 __glibcxx_check_bucket_index(__b);
1059 return { _Base::end(__b),
this };
1062 const_local_iterator
1063 begin(size_type __b)
const
1065 __glibcxx_check_bucket_index(__b);
1066 return { _Base::begin(__b),
this };
1069 const_local_iterator
1070 end(size_type __b)
const
1072 __glibcxx_check_bucket_index(__b);
1073 return { _Base::end(__b),
this };
1076 const_local_iterator
1077 cbegin(size_type __b)
const
1079 __glibcxx_check_bucket_index(__b);
1080 return { _Base::cbegin(__b),
this };
1083 const_local_iterator
1084 cend(size_type __b)
const
1086 __glibcxx_check_bucket_index(__b);
1087 return { _Base::cend(__b),
this };
1090 using _Base::bucket_count;
1091 using _Base::max_bucket_count;
1094 bucket_size(size_type __b)
const
1096 __glibcxx_check_bucket_index(__b);
1097 return _Base::bucket_size(__b);
1100 using _Base::bucket;
1101 using _Base::load_factor;
1104 max_load_factor()
const noexcept
1105 {
return _Base::max_load_factor(); }
1108 max_load_factor(
float __f)
1110 __glibcxx_check_max_load_factor(__f);
1111 _Base::max_load_factor(__f);
1114 using _Base::rehash;
1115 using _Base::reserve;
1117 template<
typename... _Args>
1119 emplace(_Args&&... __args)
1121 size_type __bucket_count = this->bucket_count();
1123 _M_check_rehashed(__bucket_count);
1124 return { __it,
this };
1127 template<
typename... _Args>
1129 emplace_hint(const_iterator __hint, _Args&&... __args)
1132 size_type __bucket_count = this->bucket_count();
1133 auto __it = _Base::emplace_hint(__hint.
base(),
1135 _M_check_rehashed(__bucket_count);
1136 return { __it,
this };
1140 insert(
const value_type& __obj)
1142 size_type __bucket_count = this->bucket_count();
1143 auto __it = _Base::insert(__obj);
1144 _M_check_rehashed(__bucket_count);
1145 return { __it,
this };
1149 insert(const_iterator __hint,
const value_type& __obj)
1152 size_type __bucket_count = this->bucket_count();
1153 auto __it = _Base::insert(__hint.
base(), __obj);
1154 _M_check_rehashed(__bucket_count);
1155 return { __it,
this };
1159 insert(value_type&& __obj)
1161 size_type __bucket_count = this->bucket_count();
1162 auto __it = _Base::insert(
std::move(__obj));
1163 _M_check_rehashed(__bucket_count);
1164 return { __it,
this };
1168 insert(const_iterator __hint, value_type&& __obj)
1171 size_type __bucket_count = this->bucket_count();
1173 _M_check_rehashed(__bucket_count);
1174 return { __it,
this };
1180 size_type __bucket_count = this->bucket_count();
1182 _M_check_rehashed(__bucket_count);
1185 template<
typename _InputIterator>
1187 insert(_InputIterator __first, _InputIterator __last)
1189 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
1190 __glibcxx_check_valid_range2(__first, __last, __dist);
1191 size_type __bucket_count = this->bucket_count();
1193 if (__dist.second >= __gnu_debug::__dp_sign)
1194 _Base::insert(__gnu_debug::__unsafe(__first),
1195 __gnu_debug::__unsafe(__last));
1197 _Base::insert(__first, __last);
1199 _M_check_rehashed(__bucket_count);
1202#ifdef __glibcxx_node_extract
1203 using node_type =
typename _Base::node_type;
1206 extract(const_iterator __position)
1209 return _M_extract(__position.
base());
1213 extract(
const key_type& __key)
1215 const auto __position = _Base::find(__key);
1216 if (__position != _Base::end())
1217 return _M_extract(__position);
1221# ifdef __glibcxx_associative_heterogeneous_erasure
1222 template <__heterogeneous_hash_key<unordered_multiset> _Kt>
1224 extract(
const _Kt& __key)
1226 const auto __position = _Base::find(__key);
1227 return __position != _Base::end() ?
1228 _M_extract(__position) : node_type{};
1233 insert(node_type&& __nh)
1234 {
return { _Base::insert(
std::move(__nh)),
this }; }
1237 insert(const_iterator __hint, node_type&& __nh)
1240 return { _Base::insert(__hint.
base(),
std::move(__nh)),
this };
1243 template<
typename _H2,
typename _P2>
1245 merge(unordered_multiset<_Value, _H2, _P2, _Alloc>& __source)
1248 = _Safe::_S_umc_guard(std::__detail::_Identity{}, __source);
1249 _Base::merge(__source);
1252 template<
typename _H2,
typename _P2>
1254 merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source)
1255 { merge(__source); }
1257 template<
typename _H2,
typename _P2>
1262 = _Safe::_S_uc_guard(std::__detail::_Identity{}, __source);
1263 _Base::merge(__source);
1266 template<
typename _H2,
typename _P2>
1269 { merge(__source); }
1272 using _Base::hash_function;
1273 using _Base::key_eq;
1276 find(
const key_type& __key)
1277 {
return { _Base::find(__key),
this }; }
1279#ifdef __glibcxx_generic_unordered_lookup
1280 template<
typename _Kt,
1281 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1282 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1284 find(
const _Kt& __k)
1285 {
return { _Base::find(__k),
this }; }
1289 find(
const key_type& __key)
const
1290 {
return { _Base::find(__key),
this }; }
1292#ifdef __glibcxx_generic_unordered_lookup
1293 template<
typename _Kt,
1294 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1295 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1297 find(
const _Kt& __k)
const
1298 {
return { _Base::find(__k),
this }; }
1303#if __cplusplus > 201703L
1304 using _Base::contains;
1308 equal_range(
const key_type& __key)
1310 auto __res = _Base::equal_range(__key);
1311 return { { __res.first,
this }, { __res.second,
this } };
1314#ifdef __glibcxx_generic_unordered_lookup
1315 template<
typename _Kt,
1316 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1317 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1319 equal_range(
const _Kt& __k)
1321 auto __res = _Base::equal_range(__k);
1322 return { { __res.first,
this }, { __res.second,
this } };
1327 equal_range(
const key_type& __key)
const
1329 auto __res = _Base::equal_range(__key);
1330 return { { __res.first,
this }, { __res.second,
this } };
1333#ifdef __glibcxx_generic_unordered_lookup
1334 template<
typename _Kt,
1335 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1336 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1338 equal_range(
const _Kt& __k)
const
1340 auto __res = _Base::equal_range(__k);
1341 return { { __res.first,
this }, { __res.second,
this } };
1346 erase(
const key_type& __key)
1348 auto __victims = _Base::equal_range(__key);
1349 return _M_erase(__victims.first, __victims.second);
1352# ifdef __glibcxx_associative_heterogeneous_erasure
1353 template <__heterogeneous_hash_key<unordered_multiset> _Kt>
1357 auto __victims = _Base::equal_range(__key);
1358 return _M_erase(__victims.first, __victims.second);
1363 erase(const_iterator __it)
1366 return { _M_erase(__it.
base()),
this };
1370 erase(_Base_const_iterator __it)
1372 __glibcxx_check_erase2(__it);
1373 return _M_erase(__it);
1377 erase(iterator __it)
1380 return { _M_erase(__it.
base()),
this };
1384 erase(const_iterator __first, const_iterator __last)
1389 for (
auto __tmp = __first.base(); __tmp != __last.
base(); ++__tmp)
1391 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(),
1392 _M_message(__gnu_debug::__msg_valid_range)
1393 ._M_iterator(__first,
"first")
1394 ._M_iterator(__last,
"last"));
1395 this->_M_invalidate(__tmp, sentry);
1399 return { _Base::erase(__first.base(), __last.
base()),
this };
1403 _M_base()
noexcept {
return *
this; }
1406 _M_base()
const noexcept {
return *
this; }
1409 const unordered_multiset*
1410 _M_self()
const noexcept
1414 _M_check_rehashed(size_type __prev_count)
1416 if (__prev_count != this->bucket_count())
1417 this->_M_invalidate_all();
1421 _M_erase(_Base_const_iterator __victim)
1423 this->_M_invalidate(__victim);
1424 return _Base::erase(__victim);
1428 _M_erase(_Base_iterator __first, _Base_iterator __last)
1430 size_type __count(0);
1433 for (
auto __victim = __first; __victim != __last; ++__victim)
1435 this->_M_invalidate(__victim, sentry);
1440 _Base::erase(__first, __last);
1444#ifdef __glibcxx_node_extract
1446 _M_extract(_Base_const_iterator __victim)
1448 this->_M_invalidate(__victim);
1449 return _Base::extract(__victim);
1454#if __cpp_deduction_guides >= 201606
1456 template<
typename _InputIterator,
1461 typename _Allocator =
1463 typename = _RequireInputIter<_InputIterator>,
1464 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1465 typename = _RequireNotAllocator<_Pred>,
1466 typename = _RequireAllocator<_Allocator>>
1468 unordered_multiset<int>::size_type = {},
1469 _Hash = _Hash(), _Pred = _Pred(),
1470 _Allocator = _Allocator())
1472 _Hash, _Pred, _Allocator>;
1474 template<
typename _Tp,
typename _Hash = hash<_Tp>,
1475 typename _Pred = equal_to<_Tp>,
1476 typename _Allocator = allocator<_Tp>,
1477 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1478 typename = _RequireNotAllocator<_Pred>,
1479 typename = _RequireAllocator<_Allocator>>
1482 _Hash = _Hash(), _Pred = _Pred(),
1483 _Allocator = _Allocator())
1484 -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>;
1486 template<
typename _InputIterator,
typename _Allocator,
1487 typename = _RequireInputIter<_InputIterator>,
1488 typename = _RequireAllocator<_Allocator>>
1489 unordered_multiset(_InputIterator, _InputIterator,
1490 unordered_multiset<int>::size_type, _Allocator)
1491 -> unordered_multiset<typename iterator_traits<_InputIterator>::value_type,
1493 iterator_traits<_InputIterator>::value_type>,
1495 iterator_traits<_InputIterator>::value_type>,
1498 template<
typename _InputIterator,
typename _Allocator,
1499 typename = _RequireInputIter<_InputIterator>,
1500 typename = _RequireAllocator<_Allocator>>
1501 unordered_multiset(_InputIterator, _InputIterator, _Allocator)
1502 -> unordered_multiset<typename iterator_traits<_InputIterator>::value_type,
1504 iterator_traits<_InputIterator>::value_type>,
1506 iterator_traits<_InputIterator>::value_type>,
1509 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
1510 typename = _RequireInputIter<_InputIterator>,
1511 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1512 typename = _RequireAllocator<_Allocator>>
1513 unordered_multiset(_InputIterator, _InputIterator,
1514 unordered_multiset<int>::size_type,
1516 -> unordered_multiset<
typename
1517 iterator_traits<_InputIterator>::value_type,
1521 iterator_traits<_InputIterator>::value_type>,
1524 template<
typename _Tp,
typename _Allocator,
1525 typename = _RequireAllocator<_Allocator>>
1526 unordered_multiset(initializer_list<_Tp>,
1527 unordered_multiset<int>::size_type, _Allocator)
1528 -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
1530 template<
typename _Tp,
typename _Allocator,
1531 typename = _RequireAllocator<_Allocator>>
1532 unordered_multiset(initializer_list<_Tp>, _Allocator)
1533 -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
1535 template<
typename _Tp,
typename _Hash,
typename _Allocator,
1536 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1537 typename = _RequireAllocator<_Allocator>>
1538 unordered_multiset(initializer_list<_Tp>,
1539 unordered_multiset<int>::size_type, _Hash, _Allocator)
1540 -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
1542#if __glibcxx_containers_ranges
1543 template<ranges::input_range _Rg,
1544 __not_allocator_like _Hash = hash<ranges::range_value_t<_Rg>>,
1545 __not_allocator_like _Pred = equal_to<ranges::range_value_t<_Rg>>,
1546 __allocator_like _Allocator = allocator<ranges::range_value_t<_Rg>>>
1547 unordered_set(from_range_t, _Rg&&, unordered_set<int>::size_type = {},
1548 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1549 ->
unordered_set<ranges::range_value_t<_Rg>, _Hash, _Pred, _Allocator>;
1551 template<ranges::input_range _Rg,
1552 __allocator_like _Allocator>
1553 unordered_set(from_range_t, _Rg&&, unordered_set<int>::size_type,
1556 hash<ranges::range_value_t<_Rg>>,
1557 equal_to<ranges::range_value_t<_Rg>>,
1560 template<ranges::input_range _Rg,
1561 __allocator_like _Allocator>
1564 hash<ranges::range_value_t<_Rg>>,
1565 equal_to<ranges::range_value_t<_Rg>>,
1568 template<ranges::input_range _Rg,
1569 __not_allocator_like _Hash,
1570 __allocator_like _Allocator>
1571 unordered_set(from_range_t, _Rg&&, unordered_set<int>::size_type,
1574 equal_to<ranges::range_value_t<_Rg>>,
1577#if __glibcxx_containers_ranges
1578 template<ranges::input_range _Rg,
1579 __not_allocator_like _Hash = hash<ranges::range_value_t<_Rg>>,
1580 __not_allocator_like _Pred = equal_to<ranges::range_value_t<_Rg>>,
1581 __allocator_like _Allocator = allocator<ranges::range_value_t<_Rg>>>
1583 unordered_multiset<int>::size_type = {},
1584 _Hash = _Hash(), _Pred = _Pred(),
1585 _Allocator = _Allocator())
1588 template<ranges::input_range _Rg,
1589 __allocator_like _Allocator>
1592 hash<ranges::range_value_t<_Rg>>,
1593 equal_to<ranges::range_value_t<_Rg>>,
1596 template<ranges::input_range _Rg,
1597 __allocator_like _Allocator>
1601 hash<ranges::range_value_t<_Rg>>,
1602 equal_to<ranges::range_value_t<_Rg>>,
1605 template<ranges::input_range _Rg,
1606 __not_allocator_like _Hash,
1607 __allocator_like _Allocator>
1609 unordered_multiset<int>::size_type,
1612 equal_to<ranges::range_value_t<_Rg>>,
1619 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
1623 noexcept(
noexcept(__x.swap(__y)))
1626 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
1630 {
return __x._M_base() == __y._M_base(); }
1632#if __cpp_impl_three_way_comparison < 201907L
1633 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
1637 {
return !(__x == __y); }
1642#ifdef __glibcxx_erase_if
1643_GLIBCXX_BEGIN_NAMESPACE_VERSION
1644 template<
typename _Key,
typename _Hash,
typename _CPred,
typename _Alloc,
1645 typename _Predicate>
1647 _CPred, _Alloc>::size_type
1650 {
return __detail::__erase_nodes_if(__cont, __cont._M_base(), __pred); }
1652 template<
typename _Key,
typename _Hash,
typename _CPred,
typename _Alloc,
1653 typename _Predicate>
1655 _CPred, _Alloc>::size_type
1658 {
return __detail::__erase_nodes_if(__cont, __cont._M_base(), __pred); }
1659_GLIBCXX_END_NAMESPACE_VERSION
#define __glibcxx_check_insert(_Position)
#define __glibcxx_check_erase_range(_First, _Last)
#define __glibcxx_check_erase(_Position)
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.
The standard allocator, as per C++03 [20.4.1].
constexpr _Iterator & base() noexcept
Return the underlying iterator.
Traits class for iterators.
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) in ...
_Hashtable::size_type size_type
Iterator-related typedefs.
A standard container composed of unique keys (containing at most one of each key value) in which the ...
_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_set with safety/checking/debug instrumentation.
Class std::unordered_multiset with safety/checking/debug instrumentation.