61#pragma GCC system_header
68#if __cplusplus >= 201103L
71#if __cplusplus > 201402L
75namespace std _GLIBCXX_VISIBILITY(default)
77_GLIBCXX_BEGIN_NAMESPACE_VERSION
79#if __cplusplus > 201103L
80# define __cpp_lib_generic_associative_lookup 201304L
99 enum _Rb_tree_color { _S_red =
false, _S_black =
true };
101 struct _Rb_tree_node_base
103 typedef _Rb_tree_node_base* _Base_ptr;
104 typedef const _Rb_tree_node_base* _Const_Base_ptr;
106 _Rb_tree_color _M_color;
112 _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPT
114 while (__x->_M_left != 0) __x = __x->_M_left;
118 static _Const_Base_ptr
119 _S_minimum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
121 while (__x->_M_left != 0) __x = __x->_M_left;
126 _S_maximum(_Base_ptr __x) _GLIBCXX_NOEXCEPT
128 while (__x->_M_right != 0) __x = __x->_M_right;
132 static _Const_Base_ptr
133 _S_maximum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
135 while (__x->_M_right != 0) __x = __x->_M_right;
141 template<
typename _Key_compare>
142 struct _Rb_tree_key_compare
144 _Key_compare _M_key_compare;
146 _Rb_tree_key_compare()
147 _GLIBCXX_NOEXCEPT_IF(
148 is_nothrow_default_constructible<_Key_compare>::value)
152 _Rb_tree_key_compare(
const _Key_compare& __comp)
153 : _M_key_compare(__comp)
156#if __cplusplus >= 201103L
158 _Rb_tree_key_compare(
const _Rb_tree_key_compare&) =
default;
160 _Rb_tree_key_compare(_Rb_tree_key_compare&& __x)
161 noexcept(is_nothrow_copy_constructible<_Key_compare>::value)
162 : _M_key_compare(__x._M_key_compare)
168 struct _Rb_tree_header
170 _Rb_tree_node_base _M_header;
171 size_t _M_node_count;
173 _Rb_tree_header() _GLIBCXX_NOEXCEPT
175 _M_header._M_color = _S_red;
179#if __cplusplus >= 201103L
180 _Rb_tree_header(_Rb_tree_header&& __x)
noexcept
182 if (__x._M_header._M_parent !=
nullptr)
186 _M_header._M_color = _S_red;
193 _M_move_data(_Rb_tree_header& __from)
195 _M_header._M_color = __from._M_header._M_color;
196 _M_header._M_parent = __from._M_header._M_parent;
197 _M_header._M_left = __from._M_header._M_left;
198 _M_header._M_right = __from._M_header._M_right;
199 _M_header._M_parent->_M_parent = &_M_header;
200 _M_node_count = __from._M_node_count;
208 _M_header._M_parent = 0;
209 _M_header._M_left = &_M_header;
210 _M_header._M_right = &_M_header;
215 template<
typename _Val>
216 struct _Rb_tree_node :
public _Rb_tree_node_base
218 typedef _Rb_tree_node<_Val>* _Link_type;
220#if __cplusplus < 201103L
231 __gnu_cxx::__aligned_membuf<_Val> _M_storage;
235 {
return _M_storage._M_ptr(); }
239 {
return _M_storage._M_ptr(); }
243 _GLIBCXX_PURE _Rb_tree_node_base*
244 _Rb_tree_increment(_Rb_tree_node_base* __x)
throw ();
246 _GLIBCXX_PURE
const _Rb_tree_node_base*
247 _Rb_tree_increment(
const _Rb_tree_node_base* __x)
throw ();
249 _GLIBCXX_PURE _Rb_tree_node_base*
250 _Rb_tree_decrement(_Rb_tree_node_base* __x)
throw ();
252 _GLIBCXX_PURE
const _Rb_tree_node_base*
253 _Rb_tree_decrement(
const _Rb_tree_node_base* __x)
throw ();
255 template<
typename _Tp>
256 struct _Rb_tree_iterator
258 typedef _Tp value_type;
259 typedef _Tp& reference;
260 typedef _Tp* pointer;
262 typedef bidirectional_iterator_tag iterator_category;
263 typedef ptrdiff_t difference_type;
265 typedef _Rb_tree_iterator<_Tp> _Self;
266 typedef _Rb_tree_node_base::_Base_ptr _Base_ptr;
267 typedef _Rb_tree_node<_Tp>* _Link_type;
269 _Rb_tree_iterator() _GLIBCXX_NOEXCEPT
273 _Rb_tree_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT
278 {
return *
static_cast<_Link_type
>(_M_node)->_M_valptr(); }
281 operator->() const _GLIBCXX_NOEXCEPT
282 {
return static_cast<_Link_type
> (_M_node)->_M_valptr(); }
285 operator++() _GLIBCXX_NOEXCEPT
287 _M_node = _Rb_tree_increment(_M_node);
292 operator++(
int) _GLIBCXX_NOEXCEPT
295 _M_node = _Rb_tree_increment(_M_node);
300 operator--() _GLIBCXX_NOEXCEPT
302 _M_node = _Rb_tree_decrement(_M_node);
307 operator--(
int) _GLIBCXX_NOEXCEPT
310 _M_node = _Rb_tree_decrement(_M_node);
315 operator==(
const _Self& __x,
const _Self& __y) _GLIBCXX_NOEXCEPT
316 {
return __x._M_node == __y._M_node; }
318#if ! __cpp_lib_three_way_comparison
320 operator!=(
const _Self& __x,
const _Self& __y) _GLIBCXX_NOEXCEPT
321 {
return __x._M_node != __y._M_node; }
327 template<
typename _Tp>
328 struct _Rb_tree_const_iterator
330 typedef _Tp value_type;
331 typedef const _Tp& reference;
332 typedef const _Tp* pointer;
334 typedef _Rb_tree_iterator<_Tp> iterator;
336 typedef bidirectional_iterator_tag iterator_category;
337 typedef ptrdiff_t difference_type;
339 typedef _Rb_tree_const_iterator<_Tp> _Self;
340 typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr;
341 typedef const _Rb_tree_node<_Tp>* _Link_type;
343 _Rb_tree_const_iterator() _GLIBCXX_NOEXCEPT
347 _Rb_tree_const_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT
350 _Rb_tree_const_iterator(
const iterator& __it) _GLIBCXX_NOEXCEPT
351 : _M_node(__it._M_node) { }
354 _M_const_cast() const _GLIBCXX_NOEXCEPT
355 {
return iterator(
const_cast<typename iterator::_Base_ptr
>(_M_node)); }
359 {
return *
static_cast<_Link_type
>(_M_node)->_M_valptr(); }
362 operator->() const _GLIBCXX_NOEXCEPT
363 {
return static_cast<_Link_type
>(_M_node)->_M_valptr(); }
366 operator++() _GLIBCXX_NOEXCEPT
368 _M_node = _Rb_tree_increment(_M_node);
373 operator++(
int) _GLIBCXX_NOEXCEPT
376 _M_node = _Rb_tree_increment(_M_node);
381 operator--() _GLIBCXX_NOEXCEPT
383 _M_node = _Rb_tree_decrement(_M_node);
388 operator--(
int) _GLIBCXX_NOEXCEPT
391 _M_node = _Rb_tree_decrement(_M_node);
396 operator==(
const _Self& __x,
const _Self& __y) _GLIBCXX_NOEXCEPT
397 {
return __x._M_node == __y._M_node; }
399#if ! __cpp_lib_three_way_comparison
401 operator!=(
const _Self& __x,
const _Self& __y) _GLIBCXX_NOEXCEPT
402 {
return __x._M_node != __y._M_node; }
408 __attribute__((__nonnull__))
410 _Rb_tree_insert_and_rebalance(
const bool __insert_left,
411 _Rb_tree_node_base* __x,
412 _Rb_tree_node_base* __p,
413 _Rb_tree_node_base& __header)
throw ();
415 __attribute__((__nonnull__,__returns_nonnull__))
417 _Rb_tree_rebalance_for_erase(_Rb_tree_node_base*
const __z,
418 _Rb_tree_node_base& __header)
throw ();
420#if __cplusplus > 201402L
421 template<
typename _Tree1,
typename _Cmp2>
422 struct _Rb_tree_merge_helper { };
425 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
426 typename _Compare,
typename _Alloc = allocator<_Val> >
430 rebind<_Rb_tree_node<_Val> >::other _Node_allocator;
435 typedef _Rb_tree_node_base* _Base_ptr;
436 typedef const _Rb_tree_node_base* _Const_Base_ptr;
437 typedef _Rb_tree_node<_Val>* _Link_type;
438 typedef const _Rb_tree_node<_Val>* _Const_Link_type;
443 struct _Reuse_or_alloc_node
445 _Reuse_or_alloc_node(_Rb_tree& __t)
446 : _M_root(__t._M_root()), _M_nodes(__t._M_rightmost()), _M_t(__t)
450 _M_root->_M_parent = 0;
452 if (_M_nodes->_M_left)
453 _M_nodes = _M_nodes->_M_left;
459#if __cplusplus >= 201103L
460 _Reuse_or_alloc_node(
const _Reuse_or_alloc_node&) =
delete;
463 ~_Reuse_or_alloc_node()
464 { _M_t._M_erase(
static_cast<_Link_type
>(_M_root)); }
466 template<
typename _Arg>
468 operator()(_GLIBCXX_FWDREF(_Arg) __arg)
470 _Link_type __node =
static_cast<_Link_type
>(_M_extract());
473 _M_t._M_destroy_node(__node);
474 _M_t._M_construct_node(__node, _GLIBCXX_FORWARD(_Arg, __arg));
478 return _M_t._M_create_node(_GLIBCXX_FORWARD(_Arg, __arg));
488 _Base_ptr __node = _M_nodes;
489 _M_nodes = _M_nodes->_M_parent;
492 if (_M_nodes->_M_right == __node)
494 _M_nodes->_M_right = 0;
496 if (_M_nodes->_M_left)
498 _M_nodes = _M_nodes->_M_left;
500 while (_M_nodes->_M_right)
501 _M_nodes = _M_nodes->_M_right;
503 if (_M_nodes->_M_left)
504 _M_nodes = _M_nodes->_M_left;
508 _M_nodes->_M_left = 0;
525 _Alloc_node(_Rb_tree& __t)
528 template<
typename _Arg>
530 operator()(_GLIBCXX_FWDREF(_Arg) __arg)
const
531 {
return _M_t._M_create_node(_GLIBCXX_FORWARD(_Arg, __arg)); }
538 typedef _Key key_type;
539 typedef _Val value_type;
540 typedef value_type* pointer;
541 typedef const value_type* const_pointer;
542 typedef value_type& reference;
543 typedef const value_type& const_reference;
544 typedef size_t size_type;
545 typedef ptrdiff_t difference_type;
546 typedef _Alloc allocator_type;
549 _M_get_Node_allocator() _GLIBCXX_NOEXCEPT
550 {
return this->_M_impl; }
552 const _Node_allocator&
553 _M_get_Node_allocator() const _GLIBCXX_NOEXCEPT
554 {
return this->_M_impl; }
557 get_allocator() const _GLIBCXX_NOEXCEPT
558 {
return allocator_type(_M_get_Node_allocator()); }
566 _M_put_node(_Link_type __p) _GLIBCXX_NOEXCEPT
569#if __cplusplus < 201103L
571 _M_construct_node(_Link_type __node,
const value_type& __x)
574 { get_allocator().construct(__node->_M_valptr(), __x); }
578 __throw_exception_again;
583 _M_create_node(
const value_type& __x)
585 _Link_type __tmp = _M_get_node();
586 _M_construct_node(__tmp, __x);
590 template<
typename... _Args>
592 _M_construct_node(_Link_type __node, _Args&&... __args)
596 ::new(__node) _Rb_tree_node<_Val>;
597 _Alloc_traits::construct(_M_get_Node_allocator(),
599 std::forward<_Args>(__args)...);
603 __node->~_Rb_tree_node<_Val>();
605 __throw_exception_again;
609 template<
typename... _Args>
611 _M_create_node(_Args&&... __args)
613 _Link_type __tmp = _M_get_node();
614 _M_construct_node(__tmp, std::forward<_Args>(__args)...);
620 _M_destroy_node(_Link_type __p) _GLIBCXX_NOEXCEPT
622#if __cplusplus < 201103L
623 get_allocator().destroy(__p->_M_valptr());
625 _Alloc_traits::destroy(_M_get_Node_allocator(), __p->_M_valptr());
626 __p->~_Rb_tree_node<_Val>();
631 _M_drop_node(_Link_type __p) _GLIBCXX_NOEXCEPT
633 _M_destroy_node(__p);
637 template<
bool _MoveValue,
typename _NodeGen>
639 _M_clone_node(_Link_type __x, _NodeGen& __node_gen)
641#if __cplusplus >= 201103L
642 using _Vp = __conditional_t<_MoveValue,
647 = __node_gen(_GLIBCXX_FORWARD(_Vp, *__x->_M_valptr()));
648 __tmp->_M_color = __x->_M_color;
655#if _GLIBCXX_INLINE_VERSION
656 template<
typename _Key_compare>
659 template<
typename _Key_compare,
660 bool = __is_pod(_Key_compare)>
663 :
public _Node_allocator
664 ,
public _Rb_tree_key_compare<_Key_compare>
665 ,
public _Rb_tree_header
667 typedef _Rb_tree_key_compare<_Key_compare> _Base_key_compare;
670 _GLIBCXX_NOEXCEPT_IF(
671 is_nothrow_default_constructible<_Node_allocator>::value
672 && is_nothrow_default_constructible<_Base_key_compare>::value )
676 _Rb_tree_impl(
const _Rb_tree_impl& __x)
677 : _Node_allocator(_Alloc_traits::_S_select_on_copy(__x))
678 , _Base_key_compare(__x._M_key_compare)
682#if __cplusplus < 201103L
683 _Rb_tree_impl(
const _Key_compare& __comp,
const _Node_allocator& __a)
684 : _Node_allocator(__a), _Base_key_compare(__comp)
687 _Rb_tree_impl(_Rb_tree_impl&&)
688 noexcept( is_nothrow_move_constructible<_Base_key_compare>::value )
692 _Rb_tree_impl(_Node_allocator&& __a)
693 : _Node_allocator(
std::
move(__a))
696 _Rb_tree_impl(_Rb_tree_impl&& __x, _Node_allocator&& __a)
697 : _Node_allocator(
std::
move(__a)),
698 _Base_key_compare(
std::
move(__x)),
699 _Rb_tree_header(
std::
move(__x))
702 _Rb_tree_impl(
const _Key_compare& __comp, _Node_allocator&& __a)
703 : _Node_allocator(
std::
move(__a)), _Base_key_compare(__comp)
708 _Rb_tree_impl<_Compare> _M_impl;
712 _M_root() _GLIBCXX_NOEXCEPT
713 {
return this->_M_impl._M_header._M_parent; }
716 _M_root() const _GLIBCXX_NOEXCEPT
717 {
return this->_M_impl._M_header._M_parent; }
720 _M_leftmost() _GLIBCXX_NOEXCEPT
721 {
return this->_M_impl._M_header._M_left; }
724 _M_leftmost() const _GLIBCXX_NOEXCEPT
725 {
return this->_M_impl._M_header._M_left; }
728 _M_rightmost() _GLIBCXX_NOEXCEPT
729 {
return this->_M_impl._M_header._M_right; }
732 _M_rightmost() const _GLIBCXX_NOEXCEPT
733 {
return this->_M_impl._M_header._M_right; }
736 _M_mbegin() const _GLIBCXX_NOEXCEPT
737 {
return static_cast<_Link_type
>(this->_M_impl._M_header._M_parent); }
740 _M_begin() _GLIBCXX_NOEXCEPT
741 {
return _M_mbegin(); }
744 _M_begin() const _GLIBCXX_NOEXCEPT
746 return static_cast<_Const_Link_type
>
747 (this->_M_impl._M_header._M_parent);
751 _M_end() _GLIBCXX_NOEXCEPT
752 {
return &this->_M_impl._M_header; }
755 _M_end() const _GLIBCXX_NOEXCEPT
756 {
return &this->_M_impl._M_header; }
759 _S_key(_Const_Link_type __x)
761#if __cplusplus >= 201103L
764 static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{},
765 "comparison object must be invocable "
766 "with two arguments of key type");
767# if __cplusplus >= 201703L
770 if constexpr (__is_invocable<_Compare&, const _Key&, const _Key&>{})
772 is_invocable_v<const _Compare&, const _Key&, const _Key&>,
773 "comparison object must be invocable as const");
777 return _KeyOfValue()(*__x->_M_valptr());
781 _S_left(_Base_ptr __x) _GLIBCXX_NOEXCEPT
782 {
return static_cast<_Link_type
>(__x->_M_left); }
784 static _Const_Link_type
785 _S_left(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
786 {
return static_cast<_Const_Link_type
>(__x->_M_left); }
789 _S_right(_Base_ptr __x) _GLIBCXX_NOEXCEPT
790 {
return static_cast<_Link_type
>(__x->_M_right); }
792 static _Const_Link_type
793 _S_right(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
794 {
return static_cast<_Const_Link_type
>(__x->_M_right); }
797 _S_key(_Const_Base_ptr __x)
798 {
return _S_key(
static_cast<_Const_Link_type
>(__x)); }
801 _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPT
802 {
return _Rb_tree_node_base::_S_minimum(__x); }
804 static _Const_Base_ptr
805 _S_minimum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
806 {
return _Rb_tree_node_base::_S_minimum(__x); }
809 _S_maximum(_Base_ptr __x) _GLIBCXX_NOEXCEPT
810 {
return _Rb_tree_node_base::_S_maximum(__x); }
812 static _Const_Base_ptr
813 _S_maximum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT
814 {
return _Rb_tree_node_base::_S_maximum(__x); }
817 typedef _Rb_tree_iterator<value_type> iterator;
818 typedef _Rb_tree_const_iterator<value_type> const_iterator;
823#if __cplusplus > 201402L
824 using node_type = _Node_handle<_Key, _Val, _Node_allocator>;
825 using insert_return_type = _Node_insert_return<
826 __conditional_t<is_same_v<_Key, _Val>, const_iterator, iterator>,
830 pair<_Base_ptr, _Base_ptr>
831 _M_get_insert_unique_pos(
const key_type& __k);
833 pair<_Base_ptr, _Base_ptr>
834 _M_get_insert_equal_pos(
const key_type& __k);
836 pair<_Base_ptr, _Base_ptr>
837 _M_get_insert_hint_unique_pos(const_iterator __pos,
838 const key_type& __k);
840 pair<_Base_ptr, _Base_ptr>
841 _M_get_insert_hint_equal_pos(const_iterator __pos,
842 const key_type& __k);
845#if __cplusplus >= 201103L
846 template<
typename _Arg,
typename _NodeGen>
848 _M_insert_(_Base_ptr __x, _Base_ptr __y, _Arg&& __v, _NodeGen&);
851 _M_insert_node(_Base_ptr __x, _Base_ptr __y, _Link_type __z);
853 template<
typename _Arg>
855 _M_insert_lower(_Base_ptr __y, _Arg&& __v);
857 template<
typename _Arg>
859 _M_insert_equal_lower(_Arg&& __x);
862 _M_insert_lower_node(_Base_ptr __p, _Link_type __z);
865 _M_insert_equal_lower_node(_Link_type __z);
867 template<
typename _NodeGen>
869 _M_insert_(_Base_ptr __x, _Base_ptr __y,
870 const value_type& __v, _NodeGen&);
875 _M_insert_lower(_Base_ptr __y,
const value_type& __v);
878 _M_insert_equal_lower(
const value_type& __x);
881 enum { __as_lvalue, __as_rvalue };
883 template<
bool _MoveValues,
typename _NodeGen>
885 _M_copy(_Link_type, _Base_ptr, _NodeGen&);
887 template<
bool _MoveValues,
typename _NodeGen>
889 _M_copy(
const _Rb_tree& __x, _NodeGen& __gen)
892 _M_copy<_MoveValues>(__x._M_mbegin(), _M_end(), __gen);
893 _M_leftmost() = _S_minimum(__root);
894 _M_rightmost() = _S_maximum(__root);
895 _M_impl._M_node_count = __x._M_impl._M_node_count;
900 _M_copy(
const _Rb_tree& __x)
902 _Alloc_node __an(*
this);
903 return _M_copy<__as_lvalue>(__x, __an);
907 _M_erase(_Link_type __x);
910 _M_lower_bound(_Link_type __x, _Base_ptr __y,
914 _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y,
915 const _Key& __k)
const;
918 _M_upper_bound(_Link_type __x, _Base_ptr __y,
922 _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y,
923 const _Key& __k)
const;
927#if __cplusplus < 201103L
930 _Rb_tree() =
default;
933 _Rb_tree(
const _Compare& __comp,
934 const allocator_type& __a = allocator_type())
935 : _M_impl(__comp, _Node_allocator(__a)) { }
937 _Rb_tree(
const _Rb_tree& __x)
938 : _M_impl(__x._M_impl)
940 if (__x._M_root() != 0)
941 _M_root() = _M_copy(__x);
944#if __cplusplus >= 201103L
945 _Rb_tree(
const allocator_type& __a)
946 : _M_impl(_Node_allocator(__a))
949 _Rb_tree(
const _Rb_tree& __x,
const allocator_type& __a)
950 : _M_impl(__x._M_impl._M_key_compare, _Node_allocator(__a))
952 if (__x._M_root() !=
nullptr)
953 _M_root() = _M_copy(__x);
956 _Rb_tree(_Rb_tree&&) =
default;
958 _Rb_tree(_Rb_tree&& __x,
const allocator_type& __a)
959 : _Rb_tree(
std::
move(__x), _Node_allocator(__a))
963 _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a,
true_type)
964 noexcept(is_nothrow_default_constructible<_Compare>::value)
968 _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a,
false_type)
969 : _M_impl(__x._M_impl._M_key_compare,
std::
move(__a))
971 if (__x._M_root() !=
nullptr)
976 _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a)
978 _Rb_tree(std::declval<_Rb_tree&&>(), std::declval<_Node_allocator&&>(),
979 std::declval<typename _Alloc_traits::is_always_equal>())) )
985 ~_Rb_tree() _GLIBCXX_NOEXCEPT
986 { _M_erase(_M_begin()); }
989 operator=(
const _Rb_tree& __x);
994 {
return _M_impl._M_key_compare; }
997 begin() _GLIBCXX_NOEXCEPT
998 {
return iterator(this->_M_impl._M_header._M_left); }
1001 begin() const _GLIBCXX_NOEXCEPT
1002 {
return const_iterator(this->_M_impl._M_header._M_left); }
1005 end() _GLIBCXX_NOEXCEPT
1006 {
return iterator(&this->_M_impl._M_header); }
1009 end() const _GLIBCXX_NOEXCEPT
1010 {
return const_iterator(&this->_M_impl._M_header); }
1013 rbegin() _GLIBCXX_NOEXCEPT
1014 {
return reverse_iterator(end()); }
1016 const_reverse_iterator
1017 rbegin() const _GLIBCXX_NOEXCEPT
1018 {
return const_reverse_iterator(end()); }
1021 rend() _GLIBCXX_NOEXCEPT
1022 {
return reverse_iterator(begin()); }
1024 const_reverse_iterator
1025 rend() const _GLIBCXX_NOEXCEPT
1026 {
return const_reverse_iterator(begin()); }
1028 _GLIBCXX_NODISCARD
bool
1029 empty() const _GLIBCXX_NOEXCEPT
1030 {
return _M_impl._M_node_count == 0; }
1033 size() const _GLIBCXX_NOEXCEPT
1034 {
return _M_impl._M_node_count; }
1037 max_size() const _GLIBCXX_NOEXCEPT
1042 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value);
1045#if __cplusplus >= 201103L
1046 template<
typename _Arg>
1047 pair<iterator, bool>
1048 _M_insert_unique(_Arg&& __x);
1050 template<
typename _Arg>
1052 _M_insert_equal(_Arg&& __x);
1054 template<
typename _Arg,
typename _NodeGen>
1056 _M_insert_unique_(const_iterator __pos, _Arg&& __x, _NodeGen&);
1058 template<
typename _Arg>
1060 _M_insert_unique_(const_iterator __pos, _Arg&& __x)
1062 _Alloc_node __an(*
this);
1063 return _M_insert_unique_(__pos, std::forward<_Arg>(__x), __an);
1066 template<
typename _Arg,
typename _NodeGen>
1068 _M_insert_equal_(const_iterator __pos, _Arg&& __x, _NodeGen&);
1070 template<
typename _Arg>
1072 _M_insert_equal_(const_iterator __pos, _Arg&& __x)
1074 _Alloc_node __an(*
this);
1075 return _M_insert_equal_(__pos, std::forward<_Arg>(__x), __an);
1078 template<
typename... _Args>
1079 pair<iterator, bool>
1080 _M_emplace_unique(_Args&&... __args);
1082 template<
typename... _Args>
1084 _M_emplace_equal(_Args&&... __args);
1086 template<
typename... _Args>
1088 _M_emplace_hint_unique(const_iterator __pos, _Args&&... __args);
1090 template<
typename... _Args>
1092 _M_emplace_hint_equal(const_iterator __pos, _Args&&... __args);
1094 template<
typename _Iter>
1095 using __same_value_type
1096 = is_same<value_type, typename iterator_traits<_Iter>::value_type>;
1098 template<
typename _InputIterator>
1099 __enable_if_t<__same_value_type<_InputIterator>::value>
1100 _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
1102 _Alloc_node __an(*
this);
1103 for (; __first != __last; ++__first)
1104 _M_insert_unique_(end(), *__first, __an);
1107 template<
typename _InputIterator>
1108 __enable_if_t<!__same_value_type<_InputIterator>::value>
1109 _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
1111 for (; __first != __last; ++__first)
1112 _M_emplace_unique(*__first);
1115 template<
typename _InputIterator>
1116 __enable_if_t<__same_value_type<_InputIterator>::value>
1117 _M_insert_range_equal(_InputIterator __first, _InputIterator __last)
1119 _Alloc_node __an(*
this);
1120 for (; __first != __last; ++__first)
1121 _M_insert_equal_(end(), *__first, __an);
1124 template<
typename _InputIterator>
1125 __enable_if_t<!__same_value_type<_InputIterator>::value>
1126 _M_insert_range_equal(_InputIterator __first, _InputIterator __last)
1128 _Alloc_node __an(*
this);
1129 for (; __first != __last; ++__first)
1130 _M_emplace_equal(*__first);
1133 pair<iterator, bool>
1134 _M_insert_unique(
const value_type& __x);
1137 _M_insert_equal(
const value_type& __x);
1139 template<
typename _NodeGen>
1141 _M_insert_unique_(const_iterator __pos,
const value_type& __x,
1145 _M_insert_unique_(const_iterator __pos,
const value_type& __x)
1147 _Alloc_node __an(*
this);
1148 return _M_insert_unique_(__pos, __x, __an);
1151 template<
typename _NodeGen>
1153 _M_insert_equal_(const_iterator __pos,
const value_type& __x,
1156 _M_insert_equal_(const_iterator __pos,
const value_type& __x)
1158 _Alloc_node __an(*
this);
1159 return _M_insert_equal_(__pos, __x, __an);
1162 template<
typename _InputIterator>
1164 _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
1166 _Alloc_node __an(*
this);
1167 for (; __first != __last; ++__first)
1168 _M_insert_unique_(end(), *__first, __an);
1171 template<
typename _InputIterator>
1173 _M_insert_range_equal(_InputIterator __first, _InputIterator __last)
1175 _Alloc_node __an(*
this);
1176 for (; __first != __last; ++__first)
1177 _M_insert_equal_(end(), *__first, __an);
1183 _M_erase_aux(const_iterator __position);
1186 _M_erase_aux(const_iterator __first, const_iterator __last);
1189#if __cplusplus >= 201103L
1192 _GLIBCXX_ABI_TAG_CXX11
1194 erase(const_iterator __position)
1196 __glibcxx_assert(__position != end());
1197 const_iterator __result = __position;
1199 _M_erase_aux(__position);
1200 return __result._M_const_cast();
1204 _GLIBCXX_ABI_TAG_CXX11
1206 erase(iterator __position)
1208 __glibcxx_assert(__position != end());
1209 iterator __result = __position;
1211 _M_erase_aux(__position);
1216 erase(iterator __position)
1218 __glibcxx_assert(__position != end());
1219 _M_erase_aux(__position);
1223 erase(const_iterator __position)
1225 __glibcxx_assert(__position != end());
1226 _M_erase_aux(__position);
1231 erase(
const key_type& __x);
1233#if __cplusplus >= 201103L
1236 _GLIBCXX_ABI_TAG_CXX11
1238 erase(const_iterator __first, const_iterator __last)
1240 _M_erase_aux(__first, __last);
1241 return __last._M_const_cast();
1245 erase(iterator __first, iterator __last)
1246 { _M_erase_aux(__first, __last); }
1249 erase(const_iterator __first, const_iterator __last)
1250 { _M_erase_aux(__first, __last); }
1254 clear() _GLIBCXX_NOEXCEPT
1256 _M_erase(_M_begin());
1262 find(
const key_type& __k);
1265 find(
const key_type& __k)
const;
1268 count(
const key_type& __k)
const;
1271 lower_bound(
const key_type& __k)
1272 {
return _M_lower_bound(_M_begin(), _M_end(), __k); }
1275 lower_bound(
const key_type& __k)
const
1276 {
return _M_lower_bound(_M_begin(), _M_end(), __k); }
1279 upper_bound(
const key_type& __k)
1280 {
return _M_upper_bound(_M_begin(), _M_end(), __k); }
1283 upper_bound(
const key_type& __k)
const
1284 {
return _M_upper_bound(_M_begin(), _M_end(), __k); }
1286 pair<iterator, iterator>
1287 equal_range(
const key_type& __k);
1289 pair<const_iterator, const_iterator>
1290 equal_range(
const key_type& __k)
const;
1292#if __cplusplus >= 201402L
1293 template<
typename _Kt,
1294 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1296 _M_find_tr(
const _Kt& __k)
1298 const _Rb_tree* __const_this =
this;
1299 return __const_this->_M_find_tr(__k)._M_const_cast();
1302 template<
typename _Kt,
1303 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1305 _M_find_tr(
const _Kt& __k)
const
1307 auto __j = _M_lower_bound_tr(__k);
1308 if (__j != end() && _M_impl._M_key_compare(__k, _S_key(__j._M_node)))
1313 template<
typename _Kt,
1314 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1316 _M_count_tr(
const _Kt& __k)
const
1318 auto __p = _M_equal_range_tr(__k);
1322 template<
typename _Kt,
1323 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1325 _M_lower_bound_tr(
const _Kt& __k)
1327 const _Rb_tree* __const_this =
this;
1328 return __const_this->_M_lower_bound_tr(__k)._M_const_cast();
1331 template<
typename _Kt,
1332 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1334 _M_lower_bound_tr(
const _Kt& __k)
const
1336 auto __x = _M_begin();
1337 auto __y = _M_end();
1339 if (!_M_impl._M_key_compare(_S_key(__x), __k))
1345 __x = _S_right(__x);
1346 return const_iterator(__y);
1349 template<
typename _Kt,
1350 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1352 _M_upper_bound_tr(
const _Kt& __k)
1354 const _Rb_tree* __const_this =
this;
1355 return __const_this->_M_upper_bound_tr(__k)._M_const_cast();
1358 template<
typename _Kt,
1359 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1361 _M_upper_bound_tr(
const _Kt& __k)
const
1363 auto __x = _M_begin();
1364 auto __y = _M_end();
1366 if (_M_impl._M_key_compare(__k, _S_key(__x)))
1372 __x = _S_right(__x);
1373 return const_iterator(__y);
1376 template<
typename _Kt,
1377 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1378 pair<iterator, iterator>
1379 _M_equal_range_tr(
const _Kt& __k)
1381 const _Rb_tree* __const_this =
this;
1382 auto __ret = __const_this->_M_equal_range_tr(__k);
1383 return { __ret.first._M_const_cast(), __ret.second._M_const_cast() };
1386 template<
typename _Kt,
1387 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1388 pair<const_iterator, const_iterator>
1389 _M_equal_range_tr(
const _Kt& __k)
const
1391 auto __low = _M_lower_bound_tr(__k);
1392 auto __high = __low;
1393 auto& __cmp = _M_impl._M_key_compare;
1394 while (__high != end() && !__cmp(__k, _S_key(__high._M_node)))
1396 return { __low, __high };
1402 __rb_verify()
const;
1404#if __cplusplus >= 201103L
1406 operator=(_Rb_tree&&)
1407 noexcept(_Alloc_traits::_S_nothrow_move()
1408 && is_nothrow_move_assignable<_Compare>::value);
1410 template<typename _Iterator>
1412 _M_assign_unique(_Iterator, _Iterator);
1414 template<typename _Iterator>
1416 _M_assign_equal(_Iterator, _Iterator);
1422 { _M_impl._M_move_data(__x._M_impl); }
1439#if __cplusplus > 201402L
1443 _M_reinsert_node_unique(node_type&& __nh)
1445 insert_return_type __ret;
1447 __ret.position = end();
1450 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1452 auto __res = _M_get_insert_unique_pos(__nh._M_key());
1456 = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1457 __nh._M_ptr =
nullptr;
1458 __ret.inserted =
true;
1463 __ret.position = iterator(__res.first);
1464 __ret.inserted =
false;
1472 _M_reinsert_node_equal(node_type&& __nh)
1479 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1480 auto __res = _M_get_insert_equal_pos(__nh._M_key());
1482 __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1484 __ret = _M_insert_equal_lower_node(__nh._M_ptr);
1485 __nh._M_ptr =
nullptr;
1492 _M_reinsert_node_hint_unique(const_iterator __hint, node_type&& __nh)
1499 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1500 auto __res = _M_get_insert_hint_unique_pos(__hint, __nh._M_key());
1503 __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1504 __nh._M_ptr =
nullptr;
1507 __ret = iterator(__res.first);
1514 _M_reinsert_node_hint_equal(const_iterator __hint, node_type&& __nh)
1521 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1522 auto __res = _M_get_insert_hint_equal_pos(__hint, __nh._M_key());
1524 __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1526 __ret = _M_insert_equal_lower_node(__nh._M_ptr);
1527 __nh._M_ptr =
nullptr;
1534 extract(const_iterator __pos)
1536 auto __ptr = _Rb_tree_rebalance_for_erase(
1537 __pos._M_const_cast()._M_node, _M_impl._M_header);
1538 --_M_impl._M_node_count;
1539 return {
static_cast<_Link_type
>(__ptr), _M_get_Node_allocator() };
1544 extract(
const key_type& __k)
1547 auto __pos = find(__k);
1549 __nh = extract(const_iterator(__pos));
1553 template<
typename _Compare2>
1554 using _Compatible_tree
1555 = _Rb_tree<_Key, _Val, _KeyOfValue, _Compare2, _Alloc>;
1557 template<
typename,
typename>
1558 friend class _Rb_tree_merge_helper;
1561 template<
typename _Compare2>
1563 _M_merge_unique(_Compatible_tree<_Compare2>& __src)
noexcept
1565 using _Merge_helper = _Rb_tree_merge_helper<_Rb_tree, _Compare2>;
1566 for (
auto __i = __src.begin(), __end = __src.end(); __i != __end;)
1569 auto __res = _M_get_insert_unique_pos(_KeyOfValue()(*__pos));
1572 auto& __src_impl = _Merge_helper::_S_get_impl(__src);
1573 auto __ptr = _Rb_tree_rebalance_for_erase(
1574 __pos._M_node, __src_impl._M_header);
1575 --__src_impl._M_node_count;
1576 _M_insert_node(__res.first, __res.second,
1577 static_cast<_Link_type
>(__ptr));
1583 template<
typename _Compare2>
1585 _M_merge_equal(_Compatible_tree<_Compare2>& __src)
noexcept
1587 using _Merge_helper = _Rb_tree_merge_helper<_Rb_tree, _Compare2>;
1588 for (
auto __i = __src.begin(), __end = __src.end(); __i != __end;)
1591 auto __res = _M_get_insert_equal_pos(_KeyOfValue()(*__pos));
1594 auto& __src_impl = _Merge_helper::_S_get_impl(__src);
1595 auto __ptr = _Rb_tree_rebalance_for_erase(
1596 __pos._M_node, __src_impl._M_header);
1597 --__src_impl._M_node_count;
1598 _M_insert_node(__res.first, __res.second,
1599 static_cast<_Link_type
>(__ptr));
1606 operator==(
const _Rb_tree& __x,
const _Rb_tree& __y)
1608 return __x.size() == __y.size()
1609 && std::equal(__x.begin(), __x.end(), __y.begin());
1612#if __cpp_lib_three_way_comparison
1614 operator<=>(
const _Rb_tree& __x,
const _Rb_tree& __y)
1616 if constexpr (
requires {
typename __detail::__synth3way_t<_Val>; })
1617 return std::lexicographical_compare_three_way(__x.begin(), __x.end(),
1618 __y.begin(), __y.end(),
1619 __detail::__synth3way);
1623 operator<(
const _Rb_tree& __x,
const _Rb_tree& __y)
1625 return std::lexicographical_compare(__x.begin(), __x.end(),
1626 __y.begin(), __y.end());
1631#if __cplusplus >= 201103L
1635 template<
typename... _Args>
1636 _Auto_node(_Rb_tree& __t, _Args&&... __args)
1638 _M_node(__t._M_create_node(
std::
forward<_Args>(__args)...))
1644 _M_t._M_drop_node(_M_node);
1647 _Auto_node(_Auto_node&& __n)
1648 : _M_t(__n._M_t), _M_node(__n._M_node)
1649 { __n._M_node =
nullptr; }
1653 {
return _S_key(_M_node); }
1656 _M_insert(pair<_Base_ptr, _Base_ptr> __p)
1658 auto __it = _M_t._M_insert_node(__p.first, __p.second, _M_node);
1664 _M_insert_equal_lower()
1666 auto __it = _M_t._M_insert_equal_lower_node(_M_node);
1677 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1678 typename _Compare,
typename _Alloc>
1680 swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
1681 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
1684#if __cplusplus >= 201103L
1685 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1686 typename _Compare,
typename _Alloc>
1688 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1691 if (_M_get_Node_allocator() == __x._M_get_Node_allocator())
1695 constexpr bool __move = !__move_if_noexcept_cond<value_type>::value;
1696 _Alloc_node __an(*
this);
1697 _M_root() = _M_copy<__move>(__x, __an);
1698 if _GLIBCXX17_CONSTEXPR (__move)
1703 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1704 typename _Compare,
typename _Alloc>
1706 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1707 _M_move_assign(_Rb_tree& __x,
true_type)
1710 if (__x._M_root() !=
nullptr)
1712 std::__alloc_on_move(_M_get_Node_allocator(),
1713 __x._M_get_Node_allocator());
1716 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1717 typename _Compare,
typename _Alloc>
1719 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1722 if (_M_get_Node_allocator() == __x._M_get_Node_allocator())
1723 return _M_move_assign(__x,
true_type{});
1727 _Reuse_or_alloc_node __roan(*
this);
1729 if (__x._M_root() !=
nullptr)
1731 _M_root() = _M_copy<__as_rvalue>(__x, __roan);
1736 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1737 typename _Compare,
typename _Alloc>
1738 inline _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&
1739 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1740 operator=(_Rb_tree&& __x)
1741 noexcept(_Alloc_traits::_S_nothrow_move()
1742 && is_nothrow_move_assignable<_Compare>::value)
1744 _M_impl._M_key_compare =
std::move(__x._M_impl._M_key_compare);
1745 _M_move_assign(__x, __bool_constant<_Alloc_traits::_S_nothrow_move()>());
1749 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1750 typename _Compare,
typename _Alloc>
1751 template<
typename _Iterator>
1753 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1754 _M_assign_unique(_Iterator __first, _Iterator __last)
1756 _Reuse_or_alloc_node __roan(*
this);
1758 for (; __first != __last; ++__first)
1759 _M_insert_unique_(
end(), *__first, __roan);
1762 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1763 typename _Compare,
typename _Alloc>
1764 template<
typename _Iterator>
1766 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1767 _M_assign_equal(_Iterator __first, _Iterator __last)
1769 _Reuse_or_alloc_node __roan(*
this);
1771 for (; __first != __last; ++__first)
1772 _M_insert_equal_(
end(), *__first, __roan);
1776 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1777 typename _Compare,
typename _Alloc>
1778 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&
1779 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1780 operator=(
const _Rb_tree& __x)
1785#if __cplusplus >= 201103L
1786 if (_Alloc_traits::_S_propagate_on_copy_assign())
1788 auto& __this_alloc = this->_M_get_Node_allocator();
1789 auto& __that_alloc = __x._M_get_Node_allocator();
1790 if (!_Alloc_traits::_S_always_equal()
1791 && __this_alloc != __that_alloc)
1796 std::__alloc_on_copy(__this_alloc, __that_alloc);
1801 _Reuse_or_alloc_node __roan(*
this);
1803 _M_impl._M_key_compare = __x._M_impl._M_key_compare;
1804 if (__x._M_root() != 0)
1805 _M_root() = _M_copy<__as_lvalue>(__x, __roan);
1811 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1812 typename _Compare,
typename _Alloc>
1813#if __cplusplus >= 201103L
1814 template<
typename _Arg,
typename _NodeGen>
1816 template<
typename _NodeGen>
1818 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1819 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1820 _M_insert_(_Base_ptr __x, _Base_ptr __p,
1821#
if __cplusplus >= 201103L
1826 _NodeGen& __node_gen)
1828 bool __insert_left = (__x != 0 || __p == _M_end()
1829 || _M_impl._M_key_compare(_KeyOfValue()(__v),
1832 _Link_type __z = __node_gen(_GLIBCXX_FORWARD(_Arg, __v));
1834 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
1835 this->_M_impl._M_header);
1836 ++_M_impl._M_node_count;
1837 return iterator(__z);
1840 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1841 typename _Compare,
typename _Alloc>
1842#if __cplusplus >= 201103L
1843 template<
typename _Arg>
1845 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1846 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1847#if __cplusplus >= 201103L
1848 _M_insert_lower(_Base_ptr __p, _Arg&& __v)
1850 _M_insert_lower(_Base_ptr __p,
const _Val& __v)
1853 bool __insert_left = (__p == _M_end()
1854 || !_M_impl._M_key_compare(_S_key(__p),
1855 _KeyOfValue()(__v)));
1857 _Link_type __z = _M_create_node(_GLIBCXX_FORWARD(_Arg, __v));
1859 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
1860 this->_M_impl._M_header);
1861 ++_M_impl._M_node_count;
1862 return iterator(__z);
1865 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1866 typename _Compare,
typename _Alloc>
1867#if __cplusplus >= 201103L
1868 template<
typename _Arg>
1870 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1871 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1872#if __cplusplus >= 201103L
1873 _M_insert_equal_lower(_Arg&& __v)
1875 _M_insert_equal_lower(
const _Val& __v)
1878 _Link_type __x = _M_begin();
1879 _Base_ptr __y = _M_end();
1883 __x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ?
1884 _S_left(__x) : _S_right(__x);
1886 return _M_insert_lower(__y, _GLIBCXX_FORWARD(_Arg, __v));
1889 template<
typename _Key,
typename _Val,
typename _KoV,
1890 typename _Compare,
typename _Alloc>
1891 template<
bool _MoveValues,
typename _NodeGen>
1892 typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type
1893 _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::
1894 _M_copy(_Link_type __x, _Base_ptr __p, _NodeGen& __node_gen)
1897 _Link_type __top = _M_clone_node<_MoveValues>(__x, __node_gen);
1898 __top->_M_parent = __p;
1904 _M_copy<_MoveValues>(_S_right(__x), __top, __node_gen);
1910 _Link_type __y = _M_clone_node<_MoveValues>(__x, __node_gen);
1912 __y->_M_parent = __p;
1914 __y->_M_right = _M_copy<_MoveValues>(_S_right(__x),
1923 __throw_exception_again;
1928 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1929 typename _Compare,
typename _Alloc>
1931 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1932 _M_erase(_Link_type __x)
1937 _M_erase(_S_right(__x));
1938 _Link_type __y = _S_left(__x);
1944 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1945 typename _Compare,
typename _Alloc>
1946 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1947 _Compare, _Alloc>::iterator
1948 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1949 _M_lower_bound(_Link_type __x, _Base_ptr __y,
1953 if (!_M_impl._M_key_compare(_S_key(__x), __k))
1954 __y = __x, __x = _S_left(__x);
1956 __x = _S_right(__x);
1957 return iterator(__y);
1960 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1961 typename _Compare,
typename _Alloc>
1962 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1963 _Compare, _Alloc>::const_iterator
1964 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1965 _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y,
1966 const _Key& __k)
const
1969 if (!_M_impl._M_key_compare(_S_key(__x), __k))
1970 __y = __x, __x = _S_left(__x);
1972 __x = _S_right(__x);
1973 return const_iterator(__y);
1976 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1977 typename _Compare,
typename _Alloc>
1978 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1979 _Compare, _Alloc>::iterator
1980 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1981 _M_upper_bound(_Link_type __x, _Base_ptr __y,
1985 if (_M_impl._M_key_compare(__k, _S_key(__x)))
1986 __y = __x, __x = _S_left(__x);
1988 __x = _S_right(__x);
1989 return iterator(__y);
1992 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1993 typename _Compare,
typename _Alloc>
1994 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1995 _Compare, _Alloc>::const_iterator
1996 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1997 _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y,
1998 const _Key& __k)
const
2001 if (_M_impl._M_key_compare(__k, _S_key(__x)))
2002 __y = __x, __x = _S_left(__x);
2004 __x = _S_right(__x);
2005 return const_iterator(__y);
2008 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2009 typename _Compare,
typename _Alloc>
2010 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2011 _Compare, _Alloc>::iterator,
2012 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2013 _Compare, _Alloc>::iterator>
2014 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2015 equal_range(
const _Key& __k)
2017 _Link_type __x = _M_begin();
2018 _Base_ptr __y = _M_end();
2021 if (_M_impl._M_key_compare(_S_key(__x), __k))
2022 __x = _S_right(__x);
2023 else if (_M_impl._M_key_compare(__k, _S_key(__x)))
2024 __y = __x, __x = _S_left(__x);
2027 _Link_type __xu(__x);
2028 _Base_ptr __yu(__y);
2029 __y = __x, __x = _S_left(__x);
2030 __xu = _S_right(__xu);
2031 return pair<iterator,
2032 iterator>(_M_lower_bound(__x, __y, __k),
2033 _M_upper_bound(__xu, __yu, __k));
2036 return pair<iterator, iterator>(iterator(__y),
2040 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2041 typename _Compare,
typename _Alloc>
2042 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2043 _Compare, _Alloc>::const_iterator,
2044 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2045 _Compare, _Alloc>::const_iterator>
2046 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2047 equal_range(
const _Key& __k)
const
2049 _Const_Link_type __x = _M_begin();
2050 _Const_Base_ptr __y = _M_end();
2053 if (_M_impl._M_key_compare(_S_key(__x), __k))
2054 __x = _S_right(__x);
2055 else if (_M_impl._M_key_compare(__k, _S_key(__x)))
2056 __y = __x, __x = _S_left(__x);
2059 _Const_Link_type __xu(__x);
2060 _Const_Base_ptr __yu(__y);
2061 __y = __x, __x = _S_left(__x);
2062 __xu = _S_right(__xu);
2063 return pair<const_iterator,
2064 const_iterator>(_M_lower_bound(__x, __y, __k),
2065 _M_upper_bound(__xu, __yu, __k));
2068 return pair<const_iterator, const_iterator>(const_iterator(__y),
2069 const_iterator(__y));
2072 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2073 typename _Compare,
typename _Alloc>
2075 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2077 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
2081 if (__t._M_root() != 0)
2082 _M_impl._M_move_data(__t._M_impl);
2084 else if (__t._M_root() == 0)
2085 __t._M_impl._M_move_data(_M_impl);
2089 std::swap(_M_leftmost(),__t._M_leftmost());
2090 std::swap(_M_rightmost(),__t._M_rightmost());
2092 _M_root()->_M_parent = _M_end();
2093 __t._M_root()->_M_parent = __t._M_end();
2094 std::swap(this->_M_impl._M_node_count, __t._M_impl._M_node_count);
2097 std::swap(this->_M_impl._M_key_compare, __t._M_impl._M_key_compare);
2099 _Alloc_traits::_S_on_swap(_M_get_Node_allocator(),
2100 __t._M_get_Node_allocator());
2103 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2104 typename _Compare,
typename _Alloc>
2105 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2106 _Compare, _Alloc>::_Base_ptr,
2107 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2108 _Compare, _Alloc>::_Base_ptr>
2109 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2110 _M_get_insert_unique_pos(
const key_type& __k)
2112 typedef pair<_Base_ptr, _Base_ptr> _Res;
2113 _Link_type __x = _M_begin();
2114 _Base_ptr __y = _M_end();
2119 __comp = _M_impl._M_key_compare(__k, _S_key(__x));
2120 __x = __comp ? _S_left(__x) : _S_right(__x);
2122 iterator __j = iterator(__y);
2126 return _Res(__x, __y);
2130 if (_M_impl._M_key_compare(_S_key(__j._M_node), __k))
2131 return _Res(__x, __y);
2132 return _Res(__j._M_node, 0);
2135 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2136 typename _Compare,
typename _Alloc>
2137 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2138 _Compare, _Alloc>::_Base_ptr,
2139 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2140 _Compare, _Alloc>::_Base_ptr>
2141 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2142 _M_get_insert_equal_pos(
const key_type& __k)
2144 typedef pair<_Base_ptr, _Base_ptr> _Res;
2145 _Link_type __x = _M_begin();
2146 _Base_ptr __y = _M_end();
2150 __x = _M_impl._M_key_compare(__k, _S_key(__x)) ?
2151 _S_left(__x) : _S_right(__x);
2153 return _Res(__x, __y);
2156 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2157 typename _Compare,
typename _Alloc>
2158#if __cplusplus >= 201103L
2159 template<
typename _Arg>
2161 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2162 _Compare, _Alloc>::iterator,
bool>
2163 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2164#if __cplusplus >= 201103L
2165 _M_insert_unique(_Arg&& __v)
2167 _M_insert_unique(
const _Val& __v)
2170 typedef pair<iterator, bool> _Res;
2171 pair<_Base_ptr, _Base_ptr> __res
2172 = _M_get_insert_unique_pos(_KeyOfValue()(__v));
2176 _Alloc_node __an(*
this);
2177 return _Res(_M_insert_(__res.first, __res.second,
2178 _GLIBCXX_FORWARD(_Arg, __v), __an),
2182 return _Res(iterator(__res.first),
false);
2185 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2186 typename _Compare,
typename _Alloc>
2187#if __cplusplus >= 201103L
2188 template<
typename _Arg>
2190 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2191 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2192#if __cplusplus >= 201103L
2193 _M_insert_equal(_Arg&& __v)
2195 _M_insert_equal(
const _Val& __v)
2198 pair<_Base_ptr, _Base_ptr> __res
2199 = _M_get_insert_equal_pos(_KeyOfValue()(__v));
2200 _Alloc_node __an(*
this);
2201 return _M_insert_(__res.first, __res.second,
2202 _GLIBCXX_FORWARD(_Arg, __v), __an);
2205 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2206 typename _Compare,
typename _Alloc>
2207 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2208 _Compare, _Alloc>::_Base_ptr,
2209 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2210 _Compare, _Alloc>::_Base_ptr>
2211 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2212 _M_get_insert_hint_unique_pos(const_iterator __position,
2213 const key_type& __k)
2215 iterator __pos = __position._M_const_cast();
2216 typedef pair<_Base_ptr, _Base_ptr> _Res;
2219 if (__pos._M_node == _M_end())
2222 && _M_impl._M_key_compare(_S_key(_M_rightmost()), __k))
2223 return _Res(0, _M_rightmost());
2225 return _M_get_insert_unique_pos(__k);
2227 else if (_M_impl._M_key_compare(__k, _S_key(__pos._M_node)))
2230 iterator __before = __pos;
2231 if (__pos._M_node == _M_leftmost())
2232 return _Res(_M_leftmost(), _M_leftmost());
2233 else if (_M_impl._M_key_compare(_S_key((--__before)._M_node), __k))
2235 if (_S_right(__before._M_node) == 0)
2236 return _Res(0, __before._M_node);
2238 return _Res(__pos._M_node, __pos._M_node);
2241 return _M_get_insert_unique_pos(__k);
2243 else if (_M_impl._M_key_compare(_S_key(__pos._M_node), __k))
2246 iterator __after = __pos;
2247 if (__pos._M_node == _M_rightmost())
2248 return _Res(0, _M_rightmost());
2249 else if (_M_impl._M_key_compare(__k, _S_key((++__after)._M_node)))
2251 if (_S_right(__pos._M_node) == 0)
2252 return _Res(0, __pos._M_node);
2254 return _Res(__after._M_node, __after._M_node);
2257 return _M_get_insert_unique_pos(__k);
2261 return _Res(__pos._M_node, 0);
2264 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2265 typename _Compare,
typename _Alloc>
2266#if __cplusplus >= 201103L
2267 template<
typename _Arg,
typename _NodeGen>
2269 template<
typename _NodeGen>
2271 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2272 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2273 _M_insert_unique_(const_iterator __position,
2274#
if __cplusplus >= 201103L
2279 _NodeGen& __node_gen)
2281 pair<_Base_ptr, _Base_ptr> __res
2282 = _M_get_insert_hint_unique_pos(__position, _KeyOfValue()(__v));
2285 return _M_insert_(__res.first, __res.second,
2286 _GLIBCXX_FORWARD(_Arg, __v),
2288 return iterator(__res.first);
2291 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2292 typename _Compare,
typename _Alloc>
2293 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2294 _Compare, _Alloc>::_Base_ptr,
2295 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2296 _Compare, _Alloc>::_Base_ptr>
2297 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2298 _M_get_insert_hint_equal_pos(const_iterator __position,
const key_type& __k)
2300 iterator __pos = __position._M_const_cast();
2301 typedef pair<_Base_ptr, _Base_ptr> _Res;
2304 if (__pos._M_node == _M_end())
2307 && !_M_impl._M_key_compare(__k, _S_key(_M_rightmost())))
2308 return _Res(0, _M_rightmost());
2310 return _M_get_insert_equal_pos(__k);
2312 else if (!_M_impl._M_key_compare(_S_key(__pos._M_node), __k))
2315 iterator __before = __pos;
2316 if (__pos._M_node == _M_leftmost())
2317 return _Res(_M_leftmost(), _M_leftmost());
2318 else if (!_M_impl._M_key_compare(__k, _S_key((--__before)._M_node)))
2320 if (_S_right(__before._M_node) == 0)
2321 return _Res(0, __before._M_node);
2323 return _Res(__pos._M_node, __pos._M_node);
2326 return _M_get_insert_equal_pos(__k);
2331 iterator __after = __pos;
2332 if (__pos._M_node == _M_rightmost())
2333 return _Res(0, _M_rightmost());
2334 else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node), __k))
2336 if (_S_right(__pos._M_node) == 0)
2337 return _Res(0, __pos._M_node);
2339 return _Res(__after._M_node, __after._M_node);
2346 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2347 typename _Compare,
typename _Alloc>
2348#if __cplusplus >= 201103L
2349 template<
typename _Arg,
typename _NodeGen>
2351 template<
typename _NodeGen>
2353 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2354 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2355 _M_insert_equal_(const_iterator __position,
2356#
if __cplusplus >= 201103L
2361 _NodeGen& __node_gen)
2363 pair<_Base_ptr, _Base_ptr> __res
2364 = _M_get_insert_hint_equal_pos(__position, _KeyOfValue()(__v));
2367 return _M_insert_(__res.first, __res.second,
2368 _GLIBCXX_FORWARD(_Arg, __v),
2371 return _M_insert_equal_lower(_GLIBCXX_FORWARD(_Arg, __v));
2374#if __cplusplus >= 201103L
2375 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2376 typename _Compare,
typename _Alloc>
2378 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2379 _M_insert_node(_Base_ptr __x, _Base_ptr __p, _Link_type __z)
2382 bool __insert_left = (__x != 0 || __p == _M_end()
2383 || _M_impl._M_key_compare(_S_key(__z),
2386 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
2387 this->_M_impl._M_header);
2388 ++_M_impl._M_node_count;
2389 return iterator(__z);
2392 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2393 typename _Compare,
typename _Alloc>
2395 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2396 _M_insert_lower_node(_Base_ptr __p, _Link_type __z)
2399 bool __insert_left = (__p == _M_end()
2400 || !_M_impl._M_key_compare(_S_key(__p),
2403 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
2404 this->_M_impl._M_header);
2405 ++_M_impl._M_node_count;
2406 return iterator(__z);
2409 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2410 typename _Compare,
typename _Alloc>
2412 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2413 _M_insert_equal_lower_node(_Link_type __z)
2416 _Link_type __x = _M_begin();
2417 _Base_ptr __y = _M_end();
2421 __x = !_M_impl._M_key_compare(_S_key(__x), _S_key(__z)) ?
2422 _S_left(__x) : _S_right(__x);
2424 return _M_insert_lower_node(__y, __z);
2427 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2428 typename _Compare,
typename _Alloc>
2429 template<
typename... _Args>
2431 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2432 _M_emplace_unique(_Args&&... __args)
2433 -> pair<iterator, bool>
2435 _Auto_node __z(*
this, std::forward<_Args>(__args)...);
2436 auto __res = _M_get_insert_unique_pos(__z._M_key());
2438 return {__z._M_insert(__res),
true};
2439 return {iterator(__res.first),
false};
2442 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2443 typename _Compare,
typename _Alloc>
2444 template<
typename... _Args>
2446 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2447 _M_emplace_equal(_Args&&... __args)
2450 _Auto_node __z(*
this, std::forward<_Args>(__args)...);
2451 auto __res = _M_get_insert_equal_pos(__z._M_key());
2452 return __z._M_insert(__res);
2455 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2456 typename _Compare,
typename _Alloc>
2457 template<
typename... _Args>
2459 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2460 _M_emplace_hint_unique(const_iterator __pos, _Args&&... __args)
2463 _Auto_node __z(*
this, std::forward<_Args>(__args)...);
2464 auto __res = _M_get_insert_hint_unique_pos(__pos, __z._M_key());
2466 return __z._M_insert(__res);
2467 return iterator(__res.first);
2470 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2471 typename _Compare,
typename _Alloc>
2472 template<
typename... _Args>
2474 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2475 _M_emplace_hint_equal(const_iterator __pos, _Args&&... __args)
2478 _Auto_node __z(*
this, std::forward<_Args>(__args)...);
2479 auto __res = _M_get_insert_hint_equal_pos(__pos, __z._M_key());
2481 return __z._M_insert(__res);
2482 return __z._M_insert_equal_lower();
2487 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2488 typename _Compare,
typename _Alloc>
2490 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2491 _M_erase_aux(const_iterator __position)
2494 static_cast<_Link_type
>(_Rb_tree_rebalance_for_erase
2495 (
const_cast<_Base_ptr
>(__position._M_node),
2496 this->_M_impl._M_header));
2498 --_M_impl._M_node_count;
2501 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2502 typename _Compare,
typename _Alloc>
2504 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2505 _M_erase_aux(const_iterator __first, const_iterator __last)
2507 if (__first ==
begin() && __last ==
end())
2510 while (__first != __last)
2511 _M_erase_aux(__first++);
2514 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2515 typename _Compare,
typename _Alloc>
2516 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
2517 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2518 erase(
const _Key& __x)
2520 pair<iterator, iterator> __p = equal_range(__x);
2521 const size_type __old_size =
size();
2522 _M_erase_aux(__p.first, __p.second);
2523 return __old_size -
size();
2526 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2527 typename _Compare,
typename _Alloc>
2528 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2529 _Compare, _Alloc>::iterator
2530 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2531 find(
const _Key& __k)
2533 iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
2534 return (__j ==
end()
2535 || _M_impl._M_key_compare(__k,
2536 _S_key(__j._M_node))) ?
end() : __j;
2539 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2540 typename _Compare,
typename _Alloc>
2541 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2542 _Compare, _Alloc>::const_iterator
2543 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2544 find(
const _Key& __k)
const
2546 const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
2547 return (__j ==
end()
2548 || _M_impl._M_key_compare(__k,
2549 _S_key(__j._M_node))) ?
end() : __j;
2552 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2553 typename _Compare,
typename _Alloc>
2554 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
2555 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2556 count(
const _Key& __k)
const
2558 pair<const_iterator, const_iterator> __p = equal_range(__k);
2563 _GLIBCXX_PURE
unsigned int
2564 _Rb_tree_black_count(
const _Rb_tree_node_base* __node,
2565 const _Rb_tree_node_base* __root)
throw ();
2567 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2568 typename _Compare,
typename _Alloc>
2570 _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::__rb_verify()
const
2572 if (_M_impl._M_node_count == 0 ||
begin() ==
end())
2573 return _M_impl._M_node_count == 0 &&
begin() ==
end()
2574 && this->_M_impl._M_header._M_left == _M_end()
2575 && this->_M_impl._M_header._M_right == _M_end();
2577 unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root());
2578 for (const_iterator __it =
begin(); __it !=
end(); ++__it)
2580 _Const_Link_type __x =
static_cast<_Const_Link_type
>(__it._M_node);
2581 _Const_Link_type __L = _S_left(__x);
2582 _Const_Link_type __R = _S_right(__x);
2584 if (__x->_M_color == _S_red)
2585 if ((__L && __L->_M_color == _S_red)
2586 || (__R && __R->_M_color == _S_red))
2589 if (__L && _M_impl._M_key_compare(_S_key(__x), _S_key(__L)))
2591 if (__R && _M_impl._M_key_compare(_S_key(__R), _S_key(__x)))
2594 if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len)
2598 if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root()))
2600 if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root()))
2605#if __cplusplus > 201402L
2607 template<
typename _Key,
typename _Val,
typename _Sel,
typename _Cmp1,
2608 typename _Alloc,
typename _Cmp2>
2609 struct _Rb_tree_merge_helper<_Rb_tree<_Key, _Val, _Sel, _Cmp1, _Alloc>,
2613 friend class _Rb_tree<_Key, _Val, _Sel, _Cmp1, _Alloc>;
2616 _S_get_impl(_Rb_tree<_Key, _Val, _Sel, _Cmp2, _Alloc>& __tree)
2617 {
return __tree._M_impl; }
2621_GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
__detected_or_t< typename is_empty< _Alloc >::type, __equal, _Alloc > is_always_equal
Whether all instances of the allocator type compare equal.
Uniform interface to C++98 and C++11 allocators.
static constexpr pointer allocate(_Alloc &__a, size_type __n)
Allocate memory.
static constexpr void deallocate(_Alloc &__a, pointer __p, size_type __n)
Deallocate memory.
static constexpr size_type max_size(const _Alloc &__a) noexcept
The maximum supported allocation size.