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)
650 for (
auto __tmp = __first.base(); __tmp != __last.
base(); ++__tmp)
652 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(),
653 _M_message(__gnu_debug::__msg_valid_range)
654 ._M_iterator(__first,
"first")
655 ._M_iterator(__last,
"last"));
656 _M_invalidate(__tmp);
659 size_type __bucket_count = this->bucket_count();
660 auto __next = _Base::erase(__first.base(), __last.
base());
661 _M_check_rehashed(__bucket_count);
662 return { __next,
this };
666 _M_base()
noexcept {
return *
this; }
669 _M_base()
const noexcept {
return *
this; }
673 _M_check_rehashed(size_type __prev_count)
675 if (__prev_count != this->bucket_count())
676 this->_M_invalidate_all();
680 _M_invalidate(_Base_const_iterator __victim)
682 this->_M_invalidate_if(
683 [__victim](_Base_const_iterator __it) {
return __it == __victim; });
684 this->_M_invalidate_local_if(
685 [__victim](_Base_const_local_iterator __it)
686 {
return __it == __victim; });
690 _M_erase(_Base_const_iterator __victim)
692 _M_invalidate(__victim);
693 size_type __bucket_count = this->bucket_count();
694 _Base_iterator __next = _Base::erase(__victim);
695 _M_check_rehashed(__bucket_count);
699#ifdef __glibcxx_node_extract
701 _M_extract(_Base_const_iterator __victim)
703 _M_invalidate(__victim);
704 return _Base::extract(__victim);
709#if __cpp_deduction_guides >= 201606
711 template<
typename _InputIterator,
716 typename _Allocator =
718 typename = _RequireInputIter<_InputIterator>,
719 typename = _RequireNotAllocatorOrIntegral<_Hash>,
720 typename = _RequireNotAllocator<_Pred>,
721 typename = _RequireAllocator<_Allocator>>
723 unordered_set<int>::size_type = {},
724 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
726 _Hash, _Pred, _Allocator>;
728 template<
typename _Tp,
typename _Hash = hash<_Tp>,
729 typename _Pred = equal_to<_Tp>,
730 typename _Allocator = allocator<_Tp>,
731 typename = _RequireNotAllocatorOrIntegral<_Hash>,
732 typename = _RequireNotAllocator<_Pred>,
733 typename = _RequireAllocator<_Allocator>>
736 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
737 -> unordered_set<_Tp, _Hash, _Pred, _Allocator>;
739 template<
typename _InputIterator,
typename _Allocator,
740 typename = _RequireInputIter<_InputIterator>,
741 typename = _RequireAllocator<_Allocator>>
742 unordered_set(_InputIterator, _InputIterator,
743 unordered_set<int>::size_type, _Allocator)
744 -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
746 typename iterator_traits<_InputIterator>::value_type>,
748 typename iterator_traits<_InputIterator>::value_type>,
751 template<
typename _InputIterator,
typename _Allocator,
752 typename = _RequireInputIter<_InputIterator>,
753 typename = _RequireAllocator<_Allocator>>
754 unordered_set(_InputIterator, _InputIterator, _Allocator)
755 -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
757 typename iterator_traits<_InputIterator>::value_type>,
759 typename iterator_traits<_InputIterator>::value_type>,
762 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
763 typename = _RequireInputIter<_InputIterator>,
764 typename = _RequireNotAllocatorOrIntegral<_Hash>,
765 typename = _RequireAllocator<_Allocator>>
766 unordered_set(_InputIterator, _InputIterator,
767 unordered_set<int>::size_type,
769 -> unordered_set<typename iterator_traits<_InputIterator>::value_type,
772 typename iterator_traits<_InputIterator>::value_type>,
775 template<
typename _Tp,
typename _Allocator,
776 typename = _RequireAllocator<_Allocator>>
777 unordered_set(initializer_list<_Tp>,
778 unordered_set<int>::size_type, _Allocator)
779 -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
781 template<
typename _Tp,
typename _Allocator,
782 typename = _RequireAllocator<_Allocator>>
783 unordered_set(initializer_list<_Tp>, _Allocator)
784 -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
786 template<
typename _Tp,
typename _Hash,
typename _Allocator,
787 typename = _RequireNotAllocatorOrIntegral<_Hash>,
788 typename = _RequireAllocator<_Allocator>>
789 unordered_set(initializer_list<_Tp>,
790 unordered_set<int>::size_type, _Hash, _Allocator)
791 -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
795 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
797 swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
798 unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
799 noexcept(
noexcept(__x.swap(__y)))
802 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
806 {
return __x._M_base() == __y._M_base(); }
808#if __cpp_impl_three_way_comparison < 201907L
809 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
813 {
return !(__x == __y); }
817 template<
typename _Value,
818 typename _Hash = std::hash<_Value>,
819 typename _Pred = std::equal_to<_Value>,
820 typename _Alloc = std::allocator<_Value> >
821 class unordered_multiset
823 unordered_multiset<_Value, _Hash, _Pred, _Alloc>, _Alloc,
824 __gnu_debug::_Safe_unordered_container>,
825 public _GLIBCXX_STD_C::unordered_multiset<_Value, _Hash, _Pred, _Alloc>
827 typedef _GLIBCXX_STD_C::unordered_multiset<
828 _Value, _Hash, _Pred, _Alloc> _Base;
831 typedef typename _Base::const_iterator _Base_const_iterator;
832 typedef typename _Base::iterator _Base_iterator;
833 typedef typename _Base::const_local_iterator
834 _Base_const_local_iterator;
835 typedef typename _Base::local_iterator _Base_local_iterator;
837 template<
typename _ItT,
typename _SeqT,
typename _CatT>
838 friend class ::__gnu_debug::_Safe_iterator;
839 template<
typename _ItT,
typename _SeqT>
840 friend class ::__gnu_debug::_Safe_local_iterator;
845 _Base_ref(
const _Base& __r) : _M_ref(__r) { }
851 typedef typename _Base::size_type size_type;
852 typedef typename _Base::difference_type difference_type;
853 typedef typename _Base::hasher hasher;
854 typedef typename _Base::key_equal key_equal;
855 typedef typename _Base::allocator_type allocator_type;
857 typedef typename _Base::key_type key_type;
858 typedef typename _Base::value_type value_type;
860 typedef typename _Base::pointer pointer;
861 typedef typename _Base::const_pointer const_pointer;
862 typedef typename _Base::reference reference;
863 typedef typename _Base::const_reference const_reference;
865 _Base_iterator, unordered_multiset> iterator;
867 _Base_const_iterator, unordered_multiset> const_iterator;
869 _Base_local_iterator, unordered_multiset> local_iterator;
871 _Base_const_local_iterator, unordered_multiset> const_local_iterator;
873 unordered_multiset() =
default;
876 unordered_multiset(size_type __n,
877 const hasher& __hf = hasher(),
878 const key_equal& __eql = key_equal(),
879 const allocator_type& __a = allocator_type())
880 : _Base(__n, __hf, __eql, __a) { }
882 template<
typename _InputIterator>
883 unordered_multiset(_InputIterator __first, _InputIterator __last,
885 const hasher& __hf = hasher(),
886 const key_equal& __eql = key_equal(),
887 const allocator_type& __a = allocator_type())
889 __glibcxx_check_valid_constructor_range(__first, __last)),
891 __hf, __eql, __a) { }
893 unordered_multiset(
const unordered_multiset&) =
default;
895 unordered_multiset(_Base_ref __x)
896 : _Base(__x._M_ref) { }
898 unordered_multiset(unordered_multiset&&) =
default;
901 unordered_multiset(
const allocator_type& __a)
904 unordered_multiset(
const unordered_multiset& __uset,
905 const allocator_type& __a)
906 : _Base(__uset, __a) { }
908 unordered_multiset(unordered_multiset&& __uset,
909 const allocator_type& __a)
910 noexcept(
noexcept(_Base(
std::move(__uset), __a)) )
916 const hasher& __hf = hasher(),
917 const key_equal& __eql = key_equal(),
918 const allocator_type& __a = allocator_type())
919 : _Base(__l, __n, __hf, __eql, __a) { }
921 unordered_multiset(size_type __n,
const allocator_type& __a)
922 : unordered_multiset(__n, hasher(), key_equal(), __a)
925 unordered_multiset(size_type __n,
const hasher& __hf,
926 const allocator_type& __a)
927 : unordered_multiset(__n, __hf, key_equal(), __a)
930 template<
typename _InputIterator>
931 unordered_multiset(_InputIterator __first, _InputIterator __last,
932 const allocator_type& __a)
933 : unordered_multiset(__first, __last, 0, hasher(), key_equal(), __a)
936 template<
typename _InputIterator>
937 unordered_multiset(_InputIterator __first, _InputIterator __last,
939 const allocator_type& __a)
940 : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a)
943 template<
typename _InputIterator>
944 unordered_multiset(_InputIterator __first, _InputIterator __last,
945 size_type __n,
const hasher& __hf,
946 const allocator_type& __a)
947 : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a)
951 const allocator_type& __a)
952 : unordered_multiset(__l, 0, hasher(), key_equal(), __a)
957 const allocator_type& __a)
958 : unordered_multiset(__l, __n, hasher(), key_equal(), __a)
962 size_type __n,
const hasher& __hf,
963 const allocator_type& __a)
964 : unordered_multiset(__l, __n, __hf, key_equal(), __a)
967#if __glibcxx_containers_ranges
968 template<__detail::__container_compatible_range<value_type> _Rg>
969 unordered_multiset(from_range_t, _Rg&& __rg,
971 const hasher& __hf = hasher(),
972 const key_equal& __eql = key_equal(),
973 const allocator_type& __a = allocator_type())
977 template<__detail::__container_compatible_range<value_type> _Rg>
978 unordered_multiset(from_range_t, _Rg&& __rg,
const allocator_type& __a)
982 template<__detail::__container_compatible_range<value_type> _Rg>
983 unordered_multiset(from_range_t, _Rg&& __rg, size_type __n,
984 const allocator_type& __a)
988 template<__detail::__container_compatible_range<value_type> _Rg>
989 unordered_multiset(from_range_t, _Rg&& __rg, size_type __n,
990 const hasher& __hf,
const allocator_type& __a)
995 ~unordered_multiset() =
default;
998 operator=(
const unordered_multiset&) =
default;
1001 operator=(unordered_multiset&&) =
default;
1006 _Base::operator=(__l);
1007 this->_M_invalidate_all();
1011 using _Base::get_allocator;
1014 using _Base::max_size;
1017 swap(unordered_multiset& __x)
1020 _Safe::_M_swap(__x);
1028 this->_M_invalidate_all();
1033 {
return { _Base::begin(),
this }; }
1036 begin()
const noexcept
1037 {
return { _Base::begin(),
this }; }
1041 {
return { _Base::end(),
this }; }
1044 end()
const noexcept
1045 {
return { _Base::end(),
this }; }
1048 cbegin()
const noexcept
1049 {
return { _Base::cbegin(),
this }; }
1052 cend()
const noexcept
1053 {
return { _Base::cend(),
this }; }
1057 begin(size_type __b)
1059 __glibcxx_check_bucket_index(__b);
1060 return { _Base::begin(__b),
this };
1066 __glibcxx_check_bucket_index(__b);
1067 return { _Base::end(__b),
this };
1070 const_local_iterator
1071 begin(size_type __b)
const
1073 __glibcxx_check_bucket_index(__b);
1074 return { _Base::begin(__b),
this };
1077 const_local_iterator
1078 end(size_type __b)
const
1080 __glibcxx_check_bucket_index(__b);
1081 return { _Base::end(__b),
this };
1084 const_local_iterator
1085 cbegin(size_type __b)
const
1087 __glibcxx_check_bucket_index(__b);
1088 return { _Base::cbegin(__b),
this };
1091 const_local_iterator
1092 cend(size_type __b)
const
1094 __glibcxx_check_bucket_index(__b);
1095 return { _Base::cend(__b),
this };
1098 using _Base::bucket_count;
1099 using _Base::max_bucket_count;
1102 bucket_size(size_type __b)
const
1104 __glibcxx_check_bucket_index(__b);
1105 return _Base::bucket_size(__b);
1108 using _Base::bucket;
1109 using _Base::load_factor;
1112 max_load_factor()
const noexcept
1113 {
return _Base::max_load_factor(); }
1116 max_load_factor(
float __f)
1118 __glibcxx_check_max_load_factor(__f);
1119 _Base::max_load_factor(__f);
1122 using _Base::rehash;
1123 using _Base::reserve;
1125 template<
typename... _Args>
1127 emplace(_Args&&... __args)
1129 size_type __bucket_count = this->bucket_count();
1131 _M_check_rehashed(__bucket_count);
1132 return { __it,
this };
1135 template<
typename... _Args>
1137 emplace_hint(const_iterator __hint, _Args&&... __args)
1140 size_type __bucket_count = this->bucket_count();
1141 auto __it = _Base::emplace_hint(__hint.
base(),
1143 _M_check_rehashed(__bucket_count);
1144 return { __it,
this };
1148 insert(
const value_type& __obj)
1150 size_type __bucket_count = this->bucket_count();
1151 auto __it = _Base::insert(__obj);
1152 _M_check_rehashed(__bucket_count);
1153 return { __it,
this };
1157 insert(const_iterator __hint,
const value_type& __obj)
1160 size_type __bucket_count = this->bucket_count();
1161 auto __it = _Base::insert(__hint.
base(), __obj);
1162 _M_check_rehashed(__bucket_count);
1163 return { __it,
this };
1167 insert(value_type&& __obj)
1169 size_type __bucket_count = this->bucket_count();
1170 auto __it = _Base::insert(
std::move(__obj));
1171 _M_check_rehashed(__bucket_count);
1172 return { __it,
this };
1176 insert(const_iterator __hint, value_type&& __obj)
1179 size_type __bucket_count = this->bucket_count();
1181 _M_check_rehashed(__bucket_count);
1182 return { __it,
this };
1188 size_type __bucket_count = this->bucket_count();
1190 _M_check_rehashed(__bucket_count);
1193 template<
typename _InputIterator>
1195 insert(_InputIterator __first, _InputIterator __last)
1197 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
1198 __glibcxx_check_valid_range2(__first, __last, __dist);
1199 size_type __bucket_count = this->bucket_count();
1201 if (__dist.second >= __gnu_debug::__dp_sign)
1202 _Base::insert(__gnu_debug::__unsafe(__first),
1203 __gnu_debug::__unsafe(__last));
1205 _Base::insert(__first, __last);
1207 _M_check_rehashed(__bucket_count);
1210#ifdef __glibcxx_node_extract
1211 using node_type =
typename _Base::node_type;
1214 extract(const_iterator __position)
1217 return _M_extract(__position.
base());
1221 extract(
const key_type& __key)
1223 const auto __position = _Base::find(__key);
1224 if (__position != _Base::end())
1225 return _M_extract(__position);
1229# ifdef __glibcxx_associative_heterogeneous_erasure
1230 template <__heterogeneous_hash_key<unordered_multiset> _Kt>
1232 extract(
const _Kt& __key)
1234 const auto __position = _Base::find(__key);
1235 return __position != _Base::end() ?
1236 _M_extract(__position) : node_type{};
1241 insert(node_type&& __nh)
1242 {
return { _Base::insert(
std::move(__nh)),
this }; }
1245 insert(const_iterator __hint, node_type&& __nh)
1248 return { _Base::insert(__hint.
base(),
std::move(__nh)),
this };
1251 template<
typename _H2,
typename _P2>
1253 merge(unordered_multiset<_Value, _H2, _P2, _Alloc>& __source)
1256 = _Safe::_S_umc_guard(std::__detail::_Identity{}, __source);
1257 _Base::merge(__source);
1260 template<
typename _H2,
typename _P2>
1262 merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source)
1263 { merge(__source); }
1265 template<
typename _H2,
typename _P2>
1270 = _Safe::_S_uc_guard(std::__detail::_Identity{}, __source);
1271 _Base::merge(__source);
1274 template<
typename _H2,
typename _P2>
1277 { merge(__source); }
1280 using _Base::hash_function;
1281 using _Base::key_eq;
1284 find(
const key_type& __key)
1285 {
return { _Base::find(__key),
this }; }
1287#ifdef __glibcxx_generic_unordered_lookup
1288 template<
typename _Kt,
1289 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1290 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1292 find(
const _Kt& __k)
1293 {
return { _Base::find(__k),
this }; }
1297 find(
const key_type& __key)
const
1298 {
return { _Base::find(__key),
this }; }
1300#ifdef __glibcxx_generic_unordered_lookup
1301 template<
typename _Kt,
1302 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1303 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1305 find(
const _Kt& __k)
const
1306 {
return { _Base::find(__k),
this }; }
1311#if __cplusplus > 201703L
1312 using _Base::contains;
1316 equal_range(
const key_type& __key)
1318 auto __res = _Base::equal_range(__key);
1319 return { { __res.first,
this }, { __res.second,
this } };
1322#ifdef __glibcxx_generic_unordered_lookup
1323 template<
typename _Kt,
1324 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1325 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1327 equal_range(
const _Kt& __k)
1329 auto __res = _Base::equal_range(__k);
1330 return { { __res.first,
this }, { __res.second,
this } };
1335 equal_range(
const key_type& __key)
const
1337 auto __res = _Base::equal_range(__key);
1338 return { { __res.first,
this }, { __res.second,
this } };
1341#ifdef __glibcxx_generic_unordered_lookup
1342 template<
typename _Kt,
1343 typename = std::__has_is_transparent_t<_Hash, _Kt>,
1344 typename = std::__has_is_transparent_t<_Pred, _Kt>>
1346 equal_range(
const _Kt& __k)
const
1348 auto __res = _Base::equal_range(__k);
1349 return { { __res.first,
this }, { __res.second,
this } };
1354 erase(
const key_type& __key)
1356 size_type __count(0);
1357 auto __victims = _Base::equal_range(__key);
1358 for (
auto __victim = __victims.first; __victim != __victims.second;)
1360 _M_invalidate(__victim);
1361 __victim = _Base::erase(__victim);
1367# ifdef __glibcxx_associative_heterogeneous_erasure
1368 template <__heterogeneous_hash_key<unordered_multiset> _Kt>
1372 size_type __count(0);
1373 auto __victims = _Base::equal_range(__key);
1374 for (
auto __victim = __victims.first; __victim != __victims.second;)
1376 _M_invalidate(__victim);
1377 __victim = _Base::erase(__victim);
1385 erase(const_iterator __it)
1388 return { _M_erase(__it.
base()),
this };
1392 erase(_Base_const_iterator __it)
1394 __glibcxx_check_erase2(__it);
1395 return _M_erase(__it);
1399 erase(iterator __it)
1402 return { _M_erase(__it.
base()),
this };
1406 erase(const_iterator __first, const_iterator __last)
1409 for (
auto __tmp = __first.base(); __tmp != __last.
base(); ++__tmp)
1411 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(),
1412 _M_message(__gnu_debug::__msg_valid_range)
1413 ._M_iterator(__first,
"first")
1414 ._M_iterator(__last,
"last"));
1415 _M_invalidate(__tmp);
1417 return { _Base::erase(__first.base(), __last.
base()),
this };
1421 _M_base()
noexcept {
return *
this; }
1424 _M_base()
const noexcept {
return *
this; }
1428 _M_check_rehashed(size_type __prev_count)
1430 if (__prev_count != this->bucket_count())
1431 this->_M_invalidate_all();
1435 _M_invalidate(_Base_const_iterator __victim)
1437 this->_M_invalidate_if(
1438 [__victim](_Base_const_iterator __it) {
return __it == __victim; });
1439 this->_M_invalidate_local_if(
1440 [__victim](_Base_const_local_iterator __it)
1441 {
return __it == __victim; });
1445 _M_erase(_Base_const_iterator __victim)
1447 _M_invalidate(__victim);
1448 size_type __bucket_count = this->bucket_count();
1449 _Base_iterator __next = _Base::erase(__victim);
1450 _M_check_rehashed(__bucket_count);
1454#ifdef __glibcxx_node_extract
1456 _M_extract(_Base_const_iterator __victim)
1458 _M_invalidate(__victim);
1459 return _Base::extract(__victim);
1464#if __cpp_deduction_guides >= 201606
1466 template<
typename _InputIterator,
1471 typename _Allocator =
1473 typename = _RequireInputIter<_InputIterator>,
1474 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1475 typename = _RequireNotAllocator<_Pred>,
1476 typename = _RequireAllocator<_Allocator>>
1478 unordered_multiset<int>::size_type = {},
1479 _Hash = _Hash(), _Pred = _Pred(),
1480 _Allocator = _Allocator())
1482 _Hash, _Pred, _Allocator>;
1484 template<
typename _Tp,
typename _Hash = hash<_Tp>,
1485 typename _Pred = equal_to<_Tp>,
1486 typename _Allocator = allocator<_Tp>,
1487 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1488 typename = _RequireNotAllocator<_Pred>,
1489 typename = _RequireAllocator<_Allocator>>
1492 _Hash = _Hash(), _Pred = _Pred(),
1493 _Allocator = _Allocator())
1494 -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>;
1496 template<
typename _InputIterator,
typename _Allocator,
1497 typename = _RequireInputIter<_InputIterator>,
1498 typename = _RequireAllocator<_Allocator>>
1499 unordered_multiset(_InputIterator, _InputIterator,
1500 unordered_multiset<int>::size_type, _Allocator)
1501 -> unordered_multiset<typename iterator_traits<_InputIterator>::value_type,
1503 iterator_traits<_InputIterator>::value_type>,
1505 iterator_traits<_InputIterator>::value_type>,
1508 template<
typename _InputIterator,
typename _Allocator,
1509 typename = _RequireInputIter<_InputIterator>,
1510 typename = _RequireAllocator<_Allocator>>
1511 unordered_multiset(_InputIterator, _InputIterator, _Allocator)
1512 -> unordered_multiset<typename iterator_traits<_InputIterator>::value_type,
1514 iterator_traits<_InputIterator>::value_type>,
1516 iterator_traits<_InputIterator>::value_type>,
1519 template<
typename _InputIterator,
typename _Hash,
typename _Allocator,
1520 typename = _RequireInputIter<_InputIterator>,
1521 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1522 typename = _RequireAllocator<_Allocator>>
1523 unordered_multiset(_InputIterator, _InputIterator,
1524 unordered_multiset<int>::size_type,
1526 -> unordered_multiset<
typename
1527 iterator_traits<_InputIterator>::value_type,
1531 iterator_traits<_InputIterator>::value_type>,
1534 template<
typename _Tp,
typename _Allocator,
1535 typename = _RequireAllocator<_Allocator>>
1536 unordered_multiset(initializer_list<_Tp>,
1537 unordered_multiset<int>::size_type, _Allocator)
1538 -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
1540 template<
typename _Tp,
typename _Allocator,
1541 typename = _RequireAllocator<_Allocator>>
1542 unordered_multiset(initializer_list<_Tp>, _Allocator)
1543 -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
1545 template<
typename _Tp,
typename _Hash,
typename _Allocator,
1546 typename = _RequireNotAllocatorOrIntegral<_Hash>,
1547 typename = _RequireAllocator<_Allocator>>
1548 unordered_multiset(initializer_list<_Tp>,
1549 unordered_multiset<int>::size_type, _Hash, _Allocator)
1550 -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>;
1552#if __glibcxx_containers_ranges
1553 template<ranges::input_range _Rg,
1554 __not_allocator_like _Hash = hash<ranges::range_value_t<_Rg>>,
1555 __not_allocator_like _Pred = equal_to<ranges::range_value_t<_Rg>>,
1556 __allocator_like _Allocator = allocator<ranges::range_value_t<_Rg>>>
1557 unordered_set(from_range_t, _Rg&&, unordered_set<int>::size_type = {},
1558 _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator())
1559 ->
unordered_set<ranges::range_value_t<_Rg>, _Hash, _Pred, _Allocator>;
1561 template<ranges::input_range _Rg,
1562 __allocator_like _Allocator>
1563 unordered_set(from_range_t, _Rg&&, unordered_set<int>::size_type,
1566 hash<ranges::range_value_t<_Rg>>,
1567 equal_to<ranges::range_value_t<_Rg>>,
1570 template<ranges::input_range _Rg,
1571 __allocator_like _Allocator>
1574 hash<ranges::range_value_t<_Rg>>,
1575 equal_to<ranges::range_value_t<_Rg>>,
1578 template<ranges::input_range _Rg,
1579 __not_allocator_like _Hash,
1580 __allocator_like _Allocator>
1581 unordered_set(from_range_t, _Rg&&, unordered_set<int>::size_type,
1584 equal_to<ranges::range_value_t<_Rg>>,
1587#if __glibcxx_containers_ranges
1588 template<ranges::input_range _Rg,
1589 __not_allocator_like _Hash = hash<ranges::range_value_t<_Rg>>,
1590 __not_allocator_like _Pred = equal_to<ranges::range_value_t<_Rg>>,
1591 __allocator_like _Allocator = allocator<ranges::range_value_t<_Rg>>>
1593 unordered_multiset<int>::size_type = {},
1594 _Hash = _Hash(), _Pred = _Pred(),
1595 _Allocator = _Allocator())
1598 template<ranges::input_range _Rg,
1599 __allocator_like _Allocator>
1602 hash<ranges::range_value_t<_Rg>>,
1603 equal_to<ranges::range_value_t<_Rg>>,
1606 template<ranges::input_range _Rg,
1607 __allocator_like _Allocator>
1611 hash<ranges::range_value_t<_Rg>>,
1612 equal_to<ranges::range_value_t<_Rg>>,
1615 template<ranges::input_range _Rg,
1616 __not_allocator_like _Hash,
1617 __allocator_like _Allocator>
1619 unordered_multiset<int>::size_type,
1622 equal_to<ranges::range_value_t<_Rg>>,
1629 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
1633 noexcept(
noexcept(__x.swap(__y)))
1636 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
1640 {
return __x._M_base() == __y._M_base(); }
1642#if __cpp_impl_three_way_comparison < 201907L
1643 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
1647 {
return !(__x == __y); }
1652#ifdef __glibcxx_erase_if
1653_GLIBCXX_BEGIN_NAMESPACE_VERSION
1654 template<
typename _Key,
typename _Hash,
typename _CPred,
typename _Alloc,
1655 typename _Predicate>
1657 _CPred, _Alloc>::size_type
1660 {
return __detail::__erase_nodes_if(__cont, __cont._M_base(), __pred); }
1662 template<
typename _Key,
typename _Hash,
typename _CPred,
typename _Alloc,
1663 typename _Predicate>
1665 _CPred, _Alloc>::size_type
1668 {
return __detail::__erase_nodes_if(__cont, __cont._M_base(), __pred); }
1669_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.