30 #ifndef _GLIBCXX_DEBUG_UNORDERED_MAP
31 #define _GLIBCXX_DEBUG_UNORDERED_MAP 1
33 #ifndef __GXX_EXPERIMENTAL_CXX0X__
42 namespace std _GLIBCXX_VISIBILITY(default)
47 template<
typename _Key,
typename _Tp,
52 :
public _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>,
54 _Hash, _Pred, _Alloc> >
56 typedef _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash,
59 typedef typename _Base::const_iterator _Base_const_iterator;
60 typedef typename _Base::iterator _Base_iterator;
61 typedef typename _Base::const_local_iterator _Base_const_local_iterator;
62 typedef typename _Base::local_iterator _Base_local_iterator;
65 typedef typename _Base::size_type size_type;
66 typedef typename _Base::hasher hasher;
67 typedef typename _Base::key_equal key_equal;
68 typedef typename _Base::allocator_type allocator_type;
70 typedef typename _Base::key_type key_type;
71 typedef typename _Base::value_type value_type;
84 const hasher& __hf = hasher(),
85 const key_equal& __eql = key_equal(),
86 const allocator_type& __a = allocator_type())
87 :
_Base(__n, __hf, __eql, __a) { }
89 template<
typename _InputIterator>
92 const hasher& __hf = hasher(),
93 const key_equal& __eql = key_equal(),
94 const allocator_type& __a = allocator_type())
109 const hasher& __hf = hasher(),
110 const key_equal& __eql = key_equal(),
111 const allocator_type& __a = allocator_type())
112 :
_Base(__l, __n, __hf, __eql, __a) { }
119 *
static_cast<_Base*
>(
this) = __x;
120 this->_M_invalidate_all();
153 this->_M_invalidate_all();
158 {
return iterator(_Base::begin(),
this); }
161 begin()
const noexcept
166 {
return iterator(_Base::end(),
this); }
173 cbegin()
const noexcept
177 cend()
const noexcept
190 begin(size_type __b)
const
194 end(size_type __b)
const
198 cbegin(size_type __b)
const
202 cend(size_type __b)
const
205 template<
typename... _Args>
207 emplace(_Args&&... __args)
209 size_type __bucket_count = this->bucket_count();
211 = _Base::emplace(std::forward<_Args>(__args)...);
212 _M_check_rehashed(__bucket_count);
216 template<
typename... _Args>
221 size_type __bucket_count = this->bucket_count();
222 _Base_iterator __it = _Base::emplace_hint(__hint.
base(),
223 std::forward<_Args>(__args)...);
224 _M_check_rehashed(__bucket_count);
229 insert(
const value_type& __obj)
231 size_type __bucket_count = this->bucket_count();
233 _M_check_rehashed(__bucket_count);
241 size_type __bucket_count = this->bucket_count();
242 _Base_iterator __it = _Base::insert(__hint.
base(), __obj);
243 _M_check_rehashed(__bucket_count);
247 template<
typename _Pair,
typename =
typename
249 _Pair&&>::value>::type>
251 insert(_Pair&& __obj)
253 size_type __bucket_count = this->bucket_count();
255 _Base::insert(std::forward<_Pair>(__obj));
256 _M_check_rehashed(__bucket_count);
260 template<
typename _Pair,
typename =
typename
262 _Pair&&>::value>::type>
267 size_type __bucket_count = this->bucket_count();
268 _Base_iterator __it =
269 _Base::insert(__hint.
base(), std::forward<_Pair>(__obj));
270 _M_check_rehashed(__bucket_count);
277 size_type __bucket_count = this->bucket_count();
279 _M_check_rehashed(__bucket_count);
282 template<
typename _InputIterator>
284 insert(_InputIterator __first, _InputIterator __last)
286 __glibcxx_check_valid_range(__first, __last);
287 size_type __bucket_count = this->bucket_count();
290 _M_check_rehashed(__bucket_count);
294 find(
const key_type& __key)
295 {
return iterator(_Base::find(__key),
this); }
298 find(
const key_type& __key)
const
302 equal_range(
const key_type& __key)
305 _Base::equal_range(__key);
311 equal_range(
const key_type& __key)
const
314 _Base::equal_range(__key);
320 erase(
const key_type& __key)
323 _Base_iterator __victim(_Base::find(__key));
324 if (__victim != _Base::end())
327 {
return __it == __victim; });
328 _Base_local_iterator __local_victim = _S_to_local(__victim);
330 [__local_victim](_Base_const_local_iterator __it)
331 {
return __it == __local_victim; });
332 size_type __bucket_count = this->bucket_count();
333 _Base::erase(__victim);
334 _M_check_rehashed(__bucket_count);
344 _Base_const_iterator __victim = __it.
base();
346 {
return __it == __victim; });
347 _Base_const_local_iterator __local_victim = _S_to_local(__victim);
349 [__local_victim](_Base_const_local_iterator __it)
350 {
return __it == __local_victim; });
351 size_type __bucket_count = this->bucket_count();
352 _Base_iterator __next = _Base::erase(__it.base());
353 _M_check_rehashed(__bucket_count);
365 for (_Base_const_iterator __tmp = __first.
base();
366 __tmp != __last.
base(); ++__tmp)
368 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(),
369 _M_message(__gnu_debug::__msg_valid_range)
370 ._M_iterator(__first,
"first")
371 ._M_iterator(__last,
"last"));
373 {
return __it == __tmp; });
374 _Base_const_local_iterator __local_tmp = _S_to_local(__tmp);
376 [__local_tmp](_Base_const_local_iterator __it)
377 {
return __it == __local_tmp; });
379 size_type __bucket_count = this->bucket_count();
380 _Base_iterator __next = _Base::erase(__first.
base(), __last.
base());
381 _M_check_rehashed(__bucket_count);
386 _M_base() noexcept {
return *
this; }
389 _M_base()
const noexcept {
return *
this; }
393 _M_invalidate_locals()
395 _Base_local_iterator __local_end = _Base::end(0);
397 [__local_end](_Base_const_local_iterator __it)
398 {
return __it != __local_end; });
404 _Base_iterator __end = _Base::end();
406 {
return __it != __end; });
407 _M_invalidate_locals();
411 _M_check_rehashed(size_type __prev_count)
413 if (__prev_count != this->bucket_count())
414 _M_invalidate_locals();
417 static _Base_local_iterator
418 _S_to_local(_Base_iterator __it)
422 return _Base_local_iterator(__it._M_cur, 0, 0);
425 static _Base_const_local_iterator
426 _S_to_local(_Base_const_iterator __it)
430 return _Base_const_local_iterator(__it._M_cur, 0, 0);
434 template<
typename _Key,
typename _Tp,
typename _Hash,
435 typename _Pred,
typename _Alloc>
441 template<
typename _Key,
typename _Tp,
typename _Hash,
442 typename _Pred,
typename _Alloc>
446 {
return __x._M_equal(__y); }
448 template<
typename _Key,
typename _Tp,
typename _Hash,
449 typename _Pred,
typename _Alloc>
451 operator!=(
const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
452 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
453 {
return !(__x == __y); }
457 template<
typename _Key,
typename _Tp,
462 :
public _GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash,
465 _Tp, _Hash, _Pred, _Alloc> >
467 typedef _GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash,
468 _Pred, _Alloc>
_Base;
471 typedef typename _Base::const_iterator _Base_const_iterator;
472 typedef typename _Base::iterator _Base_iterator;
473 typedef typename _Base::const_local_iterator _Base_const_local_iterator;
474 typedef typename _Base::local_iterator _Base_local_iterator;
477 typedef typename _Base::size_type size_type;
478 typedef typename _Base::hasher hasher;
479 typedef typename _Base::key_equal key_equal;
480 typedef typename _Base::allocator_type allocator_type;
482 typedef typename _Base::key_type key_type;
483 typedef typename _Base::value_type value_type;
496 const hasher& __hf = hasher(),
497 const key_equal& __eql = key_equal(),
498 const allocator_type& __a = allocator_type())
499 :
_Base(__n, __hf, __eql, __a) { }
501 template<
typename _InputIterator>
504 const hasher& __hf = hasher(),
505 const key_equal& __eql = key_equal(),
506 const allocator_type& __a = allocator_type())
510 __hf, __eql, __a) { }
521 const hasher& __hf = hasher(),
522 const key_equal& __eql = key_equal(),
523 const allocator_type& __a = allocator_type())
524 :
_Base(__l, __n, __hf, __eql, __a) { }
531 *
static_cast<_Base*
>(
this) = __x;
532 this->_M_invalidate_all();
565 this->_M_invalidate_all();
570 {
return iterator(_Base::begin(),
this); }
573 begin()
const noexcept
578 {
return iterator(_Base::end(),
this); }
585 cbegin()
const noexcept
589 cend()
const noexcept
602 begin(size_type __b)
const
606 end(size_type __b)
const
610 cbegin(size_type __b)
const
614 cend(size_type __b)
const
617 template<
typename... _Args>
619 emplace(_Args&&... __args)
621 size_type __bucket_count = this->bucket_count();
623 = _Base::emplace(std::forward<_Args>(__args)...);
624 _M_check_rehashed(__bucket_count);
628 template<
typename... _Args>
633 size_type __bucket_count = this->bucket_count();
634 _Base_iterator __it = _Base::emplace_hint(__hint.
base(),
635 std::forward<_Args>(__args)...);
636 _M_check_rehashed(__bucket_count);
641 insert(
const value_type& __obj)
643 size_type __bucket_count = this->bucket_count();
644 _Base_iterator __it = _Base::insert(__obj);
645 _M_check_rehashed(__bucket_count);
653 size_type __bucket_count = this->bucket_count();
654 _Base_iterator __it = _Base::insert(__hint.
base(), __obj);
655 _M_check_rehashed(__bucket_count);
659 template<
typename _Pair,
typename =
typename
661 _Pair&&>::value>::type>
663 insert(_Pair&& __obj)
665 size_type __bucket_count = this->bucket_count();
666 _Base_iterator __it = _Base::insert(std::forward<_Pair>(__obj));
667 _M_check_rehashed(__bucket_count);
671 template<
typename _Pair,
typename =
typename
673 _Pair&&>::value>::type>
678 size_type __bucket_count = this->bucket_count();
679 _Base_iterator __it =
680 _Base::insert(__hint.
base(), std::forward<_Pair>(__obj));
681 _M_check_rehashed(__bucket_count);
687 { _Base::insert(__l); }
689 template<
typename _InputIterator>
691 insert(_InputIterator __first, _InputIterator __last)
693 __glibcxx_check_valid_range(__first, __last);
694 size_type __bucket_count = this->bucket_count();
697 _M_check_rehashed(__bucket_count);
701 find(
const key_type& __key)
702 {
return iterator(_Base::find(__key),
this); }
705 find(
const key_type& __key)
const
709 equal_range(
const key_type& __key)
712 _Base::equal_range(__key);
718 equal_range(
const key_type& __key)
const
721 _Base::equal_range(__key);
727 erase(
const key_type& __key)
730 size_type __bucket_count = this->bucket_count();
732 _Base::equal_range(__key);
733 for (_Base_iterator __victim = __pair.
first; __victim != __pair.
second;)
736 {
return __it == __victim; });
737 _Base_local_iterator __local_victim = _S_to_local(__victim);
739 [__local_victim](_Base_const_local_iterator __it)
740 {
return __it == __local_victim; });
741 _Base::erase(__victim++);
744 _M_check_rehashed(__bucket_count);
752 _Base_const_iterator __victim = __it.
base();
754 {
return __it == __victim; });
755 _Base_const_local_iterator __local_victim = _S_to_local(__victim);
757 [__local_victim](_Base_const_local_iterator __it)
758 {
return __it == __local_victim; });
759 size_type __bucket_count = this->bucket_count();
760 _Base_iterator __next = _Base::erase(__it.base());
761 _M_check_rehashed(__bucket_count);
773 for (_Base_const_iterator __tmp = __first.
base();
774 __tmp != __last.
base(); ++__tmp)
776 _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(),
777 _M_message(__gnu_debug::__msg_valid_range)
778 ._M_iterator(__first,
"first")
779 ._M_iterator(__last,
"last"));
781 {
return __it == __tmp; });
782 _Base_const_local_iterator __local_tmp = _S_to_local(__tmp);
784 [__local_tmp](_Base_const_local_iterator __it)
785 {
return __it == __local_tmp; });
787 size_type __bucket_count = this->bucket_count();
788 _Base_iterator __next = _Base::erase(__first.
base(), __last.
base());
789 _M_check_rehashed(__bucket_count);
794 _M_base() noexcept {
return *
this; }
797 _M_base()
const noexcept {
return *
this; }
801 _M_invalidate_locals()
803 _Base_local_iterator __local_end = _Base::end(0);
805 [__local_end](_Base_const_local_iterator __it)
806 {
return __it != __local_end; });
812 _Base_iterator __end = _Base::end();
814 {
return __it != __end; });
815 _M_invalidate_locals();
819 _M_check_rehashed(size_type __prev_count)
821 if (__prev_count != this->bucket_count())
822 _M_invalidate_locals();
825 static _Base_local_iterator
826 _S_to_local(_Base_iterator __it)
830 return _Base_local_iterator(__it._M_cur, 0, 0);
833 static _Base_const_local_iterator
834 _S_to_local(_Base_const_iterator __it)
838 return _Base_const_local_iterator(__it._M_cur, 0, 0);
842 template<
typename _Key,
typename _Tp,
typename _Hash,
843 typename _Pred,
typename _Alloc>
849 template<
typename _Key,
typename _Tp,
typename _Hash,
850 typename _Pred,
typename _Alloc>
854 {
return __x._M_equal(__y); }
856 template<
typename _Key,
typename _Tp,
typename _Hash,
857 typename _Pred,
typename _Alloc>
859 operator!=(
const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
860 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
861 {
return !(__x == __y); }
866 #endif // __GXX_EXPERIMENTAL_CXX0X__
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
_T1 first
second_type is the second bound type
Base class for constructing a safe unordered container type that tracks iterators that reference it...
_T2 second
first is a copy of the first object
The standard allocator, as per [20.4].
#define __glibcxx_check_erase_range(_First, _Last)
void _M_invalidate_local_if(_Predicate __pred)
Class std::unordered_multimap with safety/checking/debug instrumentation.
_Iterator base() const
Return the underlying iterator.
#define __glibcxx_check_erase(_Position)
A standard container composed of unique keys (containing at most one of each key value) that associat...
One of the comparison functors.
void _M_invalidate_if(_Predicate __pred)
Define a member typedef type only if a boolean constant is true.
void _M_swap(_Safe_unordered_container_base &__x)
Class std::unordered_map with safety/checking/debug instrumentation.
Base class that supports tracking of iterators that reference a sequence.
#define __glibcxx_check_insert(_Position)
Struct holding two objects of arbitrary type.
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
A standard container composed of equivalent keys (possibly containing multiple of each key value) tha...
Primary class template hash.