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 for (; __first != __last; ++__first)
1129 _M_emplace_equal(*__first);
1132 pair<iterator, bool>
1133 _M_insert_unique(
const value_type& __x);
1136 _M_insert_equal(
const value_type& __x);
1138 template<
typename _NodeGen>
1140 _M_insert_unique_(const_iterator __pos,
const value_type& __x,
1144 _M_insert_unique_(const_iterator __pos,
const value_type& __x)
1146 _Alloc_node __an(*
this);
1147 return _M_insert_unique_(__pos, __x, __an);
1150 template<
typename _NodeGen>
1152 _M_insert_equal_(const_iterator __pos,
const value_type& __x,
1155 _M_insert_equal_(const_iterator __pos,
const value_type& __x)
1157 _Alloc_node __an(*
this);
1158 return _M_insert_equal_(__pos, __x, __an);
1161 template<
typename _InputIterator>
1163 _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
1165 _Alloc_node __an(*
this);
1166 for (; __first != __last; ++__first)
1167 _M_insert_unique_(end(), *__first, __an);
1170 template<
typename _InputIterator>
1172 _M_insert_range_equal(_InputIterator __first, _InputIterator __last)
1174 _Alloc_node __an(*
this);
1175 for (; __first != __last; ++__first)
1176 _M_insert_equal_(end(), *__first, __an);
1182 _M_erase_aux(const_iterator __position);
1185 _M_erase_aux(const_iterator __first, const_iterator __last);
1188#if __cplusplus >= 201103L
1191 _GLIBCXX_ABI_TAG_CXX11
1193 erase(const_iterator __position)
1195 __glibcxx_assert(__position != end());
1196 const_iterator __result = __position;
1198 _M_erase_aux(__position);
1199 return __result._M_const_cast();
1203 _GLIBCXX_ABI_TAG_CXX11
1205 erase(iterator __position)
1207 __glibcxx_assert(__position != end());
1208 iterator __result = __position;
1210 _M_erase_aux(__position);
1215 erase(iterator __position)
1217 __glibcxx_assert(__position != end());
1218 _M_erase_aux(__position);
1222 erase(const_iterator __position)
1224 __glibcxx_assert(__position != end());
1225 _M_erase_aux(__position);
1230 erase(
const key_type& __x);
1232#if __cplusplus >= 201103L
1235 _GLIBCXX_ABI_TAG_CXX11
1237 erase(const_iterator __first, const_iterator __last)
1239 _M_erase_aux(__first, __last);
1240 return __last._M_const_cast();
1244 erase(iterator __first, iterator __last)
1245 { _M_erase_aux(__first, __last); }
1248 erase(const_iterator __first, const_iterator __last)
1249 { _M_erase_aux(__first, __last); }
1253 clear() _GLIBCXX_NOEXCEPT
1255 _M_erase(_M_begin());
1261 find(
const key_type& __k);
1264 find(
const key_type& __k)
const;
1267 count(
const key_type& __k)
const;
1270 lower_bound(
const key_type& __k)
1271 {
return _M_lower_bound(_M_begin(), _M_end(), __k); }
1274 lower_bound(
const key_type& __k)
const
1275 {
return _M_lower_bound(_M_begin(), _M_end(), __k); }
1278 upper_bound(
const key_type& __k)
1279 {
return _M_upper_bound(_M_begin(), _M_end(), __k); }
1282 upper_bound(
const key_type& __k)
const
1283 {
return _M_upper_bound(_M_begin(), _M_end(), __k); }
1285 pair<iterator, iterator>
1286 equal_range(
const key_type& __k);
1288 pair<const_iterator, const_iterator>
1289 equal_range(
const key_type& __k)
const;
1291#if __cplusplus >= 201402L
1292 template<
typename _Kt,
1293 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1295 _M_find_tr(
const _Kt& __k)
1297 const _Rb_tree* __const_this =
this;
1298 return __const_this->_M_find_tr(__k)._M_const_cast();
1301 template<
typename _Kt,
1302 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1304 _M_find_tr(
const _Kt& __k)
const
1306 auto __j = _M_lower_bound_tr(__k);
1307 if (__j != end() && _M_impl._M_key_compare(__k, _S_key(__j._M_node)))
1312 template<
typename _Kt,
1313 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1315 _M_count_tr(
const _Kt& __k)
const
1317 auto __p = _M_equal_range_tr(__k);
1321 template<
typename _Kt,
1322 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1324 _M_lower_bound_tr(
const _Kt& __k)
1326 const _Rb_tree* __const_this =
this;
1327 return __const_this->_M_lower_bound_tr(__k)._M_const_cast();
1330 template<
typename _Kt,
1331 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1333 _M_lower_bound_tr(
const _Kt& __k)
const
1335 auto __x = _M_begin();
1336 auto __y = _M_end();
1338 if (!_M_impl._M_key_compare(_S_key(__x), __k))
1344 __x = _S_right(__x);
1345 return const_iterator(__y);
1348 template<
typename _Kt,
1349 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1351 _M_upper_bound_tr(
const _Kt& __k)
1353 const _Rb_tree* __const_this =
this;
1354 return __const_this->_M_upper_bound_tr(__k)._M_const_cast();
1357 template<
typename _Kt,
1358 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1360 _M_upper_bound_tr(
const _Kt& __k)
const
1362 auto __x = _M_begin();
1363 auto __y = _M_end();
1365 if (_M_impl._M_key_compare(__k, _S_key(__x)))
1371 __x = _S_right(__x);
1372 return const_iterator(__y);
1375 template<
typename _Kt,
1376 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1377 pair<iterator, iterator>
1378 _M_equal_range_tr(
const _Kt& __k)
1380 const _Rb_tree* __const_this =
this;
1381 auto __ret = __const_this->_M_equal_range_tr(__k);
1382 return { __ret.first._M_const_cast(), __ret.second._M_const_cast() };
1385 template<
typename _Kt,
1386 typename _Req = __has_is_transparent_t<_Compare, _Kt>>
1387 pair<const_iterator, const_iterator>
1388 _M_equal_range_tr(
const _Kt& __k)
const
1390 auto __low = _M_lower_bound_tr(__k);
1391 auto __high = __low;
1392 auto& __cmp = _M_impl._M_key_compare;
1393 while (__high != end() && !__cmp(__k, _S_key(__high._M_node)))
1395 return { __low, __high };
1401 __rb_verify()
const;
1403#if __cplusplus >= 201103L
1405 operator=(_Rb_tree&&)
1406 noexcept(_Alloc_traits::_S_nothrow_move()
1407 && is_nothrow_move_assignable<_Compare>::value);
1409 template<typename _Iterator>
1411 _M_assign_unique(_Iterator, _Iterator);
1413 template<typename _Iterator>
1415 _M_assign_equal(_Iterator, _Iterator);
1421 { _M_impl._M_move_data(__x._M_impl); }
1438#if __cplusplus > 201402L
1442 _M_reinsert_node_unique(node_type&& __nh)
1444 insert_return_type __ret;
1446 __ret.position = end();
1449 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1451 auto __res = _M_get_insert_unique_pos(__nh._M_key());
1455 = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1456 __nh._M_ptr =
nullptr;
1457 __ret.inserted =
true;
1462 __ret.position = iterator(__res.first);
1463 __ret.inserted =
false;
1471 _M_reinsert_node_equal(node_type&& __nh)
1478 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1479 auto __res = _M_get_insert_equal_pos(__nh._M_key());
1481 __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1483 __ret = _M_insert_equal_lower_node(__nh._M_ptr);
1484 __nh._M_ptr =
nullptr;
1491 _M_reinsert_node_hint_unique(const_iterator __hint, node_type&& __nh)
1498 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1499 auto __res = _M_get_insert_hint_unique_pos(__hint, __nh._M_key());
1502 __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1503 __nh._M_ptr =
nullptr;
1506 __ret = iterator(__res.first);
1513 _M_reinsert_node_hint_equal(const_iterator __hint, node_type&& __nh)
1520 __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc);
1521 auto __res = _M_get_insert_hint_equal_pos(__hint, __nh._M_key());
1523 __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr);
1525 __ret = _M_insert_equal_lower_node(__nh._M_ptr);
1526 __nh._M_ptr =
nullptr;
1533 extract(const_iterator __pos)
1535 auto __ptr = _Rb_tree_rebalance_for_erase(
1536 __pos._M_const_cast()._M_node, _M_impl._M_header);
1537 --_M_impl._M_node_count;
1538 return {
static_cast<_Link_type
>(__ptr), _M_get_Node_allocator() };
1543 extract(
const key_type& __k)
1546 auto __pos = find(__k);
1548 __nh = extract(const_iterator(__pos));
1552 template<
typename _Compare2>
1553 using _Compatible_tree
1554 = _Rb_tree<_Key, _Val, _KeyOfValue, _Compare2, _Alloc>;
1556 template<
typename,
typename>
1557 friend class _Rb_tree_merge_helper;
1560 template<
typename _Compare2>
1562 _M_merge_unique(_Compatible_tree<_Compare2>& __src)
noexcept
1564 using _Merge_helper = _Rb_tree_merge_helper<_Rb_tree, _Compare2>;
1565 for (
auto __i = __src.begin(), __end = __src.end(); __i != __end;)
1568 auto __res = _M_get_insert_unique_pos(_KeyOfValue()(*__pos));
1571 auto& __src_impl = _Merge_helper::_S_get_impl(__src);
1572 auto __ptr = _Rb_tree_rebalance_for_erase(
1573 __pos._M_node, __src_impl._M_header);
1574 --__src_impl._M_node_count;
1575 _M_insert_node(__res.first, __res.second,
1576 static_cast<_Link_type
>(__ptr));
1582 template<
typename _Compare2>
1584 _M_merge_equal(_Compatible_tree<_Compare2>& __src)
noexcept
1586 using _Merge_helper = _Rb_tree_merge_helper<_Rb_tree, _Compare2>;
1587 for (
auto __i = __src.begin(), __end = __src.end(); __i != __end;)
1590 auto __res = _M_get_insert_equal_pos(_KeyOfValue()(*__pos));
1593 auto& __src_impl = _Merge_helper::_S_get_impl(__src);
1594 auto __ptr = _Rb_tree_rebalance_for_erase(
1595 __pos._M_node, __src_impl._M_header);
1596 --__src_impl._M_node_count;
1597 _M_insert_node(__res.first, __res.second,
1598 static_cast<_Link_type
>(__ptr));
1605 operator==(
const _Rb_tree& __x,
const _Rb_tree& __y)
1607 return __x.size() == __y.size()
1608 && std::equal(__x.begin(), __x.end(), __y.begin());
1611#if __cpp_lib_three_way_comparison
1613 operator<=>(
const _Rb_tree& __x,
const _Rb_tree& __y)
1615 if constexpr (
requires {
typename __detail::__synth3way_t<_Val>; })
1616 return std::lexicographical_compare_three_way(__x.begin(), __x.end(),
1617 __y.begin(), __y.end(),
1618 __detail::__synth3way);
1622 operator<(
const _Rb_tree& __x,
const _Rb_tree& __y)
1624 return std::lexicographical_compare(__x.begin(), __x.end(),
1625 __y.begin(), __y.end());
1630#if __cplusplus >= 201103L
1634 template<
typename... _Args>
1635 _Auto_node(_Rb_tree& __t, _Args&&... __args)
1637 _M_node(__t._M_create_node(
std::
forward<_Args>(__args)...))
1643 _M_t._M_drop_node(_M_node);
1646 _Auto_node(_Auto_node&& __n)
1647 : _M_t(__n._M_t), _M_node(__n._M_node)
1648 { __n._M_node =
nullptr; }
1652 {
return _S_key(_M_node); }
1655 _M_insert(pair<_Base_ptr, _Base_ptr> __p)
1657 auto __it = _M_t._M_insert_node(__p.first, __p.second, _M_node);
1663 _M_insert_equal_lower()
1665 auto __it = _M_t._M_insert_equal_lower_node(_M_node);
1676 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1677 typename _Compare,
typename _Alloc>
1679 swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
1680 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y)
1683#if __cplusplus >= 201103L
1684 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1685 typename _Compare,
typename _Alloc>
1687 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1690 if (_M_get_Node_allocator() == __x._M_get_Node_allocator())
1694 constexpr bool __move = !__move_if_noexcept_cond<value_type>::value;
1695 _Alloc_node __an(*
this);
1696 _M_root() = _M_copy<__move>(__x, __an);
1697 if _GLIBCXX17_CONSTEXPR (__move)
1702 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1703 typename _Compare,
typename _Alloc>
1705 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1706 _M_move_assign(_Rb_tree& __x,
true_type)
1709 if (__x._M_root() !=
nullptr)
1711 std::__alloc_on_move(_M_get_Node_allocator(),
1712 __x._M_get_Node_allocator());
1715 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1716 typename _Compare,
typename _Alloc>
1718 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1721 if (_M_get_Node_allocator() == __x._M_get_Node_allocator())
1722 return _M_move_assign(__x,
true_type{});
1726 _Reuse_or_alloc_node __roan(*
this);
1728 if (__x._M_root() !=
nullptr)
1730 _M_root() = _M_copy<__as_rvalue>(__x, __roan);
1735 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1736 typename _Compare,
typename _Alloc>
1737 inline _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&
1738 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1739 operator=(_Rb_tree&& __x)
1740 noexcept(_Alloc_traits::_S_nothrow_move()
1741 && is_nothrow_move_assignable<_Compare>::value)
1743 _M_impl._M_key_compare =
std::move(__x._M_impl._M_key_compare);
1744 _M_move_assign(__x, __bool_constant<_Alloc_traits::_S_nothrow_move()>());
1748 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1749 typename _Compare,
typename _Alloc>
1750 template<
typename _Iterator>
1752 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1753 _M_assign_unique(_Iterator __first, _Iterator __last)
1755 _Reuse_or_alloc_node __roan(*
this);
1757 for (; __first != __last; ++__first)
1758 _M_insert_unique_(
end(), *__first, __roan);
1761 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1762 typename _Compare,
typename _Alloc>
1763 template<
typename _Iterator>
1765 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1766 _M_assign_equal(_Iterator __first, _Iterator __last)
1768 _Reuse_or_alloc_node __roan(*
this);
1770 for (; __first != __last; ++__first)
1771 _M_insert_equal_(
end(), *__first, __roan);
1775 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1776 typename _Compare,
typename _Alloc>
1777 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&
1778 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1779 operator=(
const _Rb_tree& __x)
1784#if __cplusplus >= 201103L
1785 if (_Alloc_traits::_S_propagate_on_copy_assign())
1787 auto& __this_alloc = this->_M_get_Node_allocator();
1788 auto& __that_alloc = __x._M_get_Node_allocator();
1789 if (!_Alloc_traits::_S_always_equal()
1790 && __this_alloc != __that_alloc)
1795 std::__alloc_on_copy(__this_alloc, __that_alloc);
1800 _Reuse_or_alloc_node __roan(*
this);
1802 _M_impl._M_key_compare = __x._M_impl._M_key_compare;
1803 if (__x._M_root() != 0)
1804 _M_root() = _M_copy<__as_lvalue>(__x, __roan);
1810 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1811 typename _Compare,
typename _Alloc>
1812#if __cplusplus >= 201103L
1813 template<
typename _Arg,
typename _NodeGen>
1815 template<
typename _NodeGen>
1817 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1818 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1819 _M_insert_(_Base_ptr __x, _Base_ptr __p,
1820#
if __cplusplus >= 201103L
1825 _NodeGen& __node_gen)
1827 bool __insert_left = (__x != 0 || __p == _M_end()
1828 || _M_impl._M_key_compare(_KeyOfValue()(__v),
1831 _Link_type __z = __node_gen(_GLIBCXX_FORWARD(_Arg, __v));
1833 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
1834 this->_M_impl._M_header);
1835 ++_M_impl._M_node_count;
1836 return iterator(__z);
1839 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1840 typename _Compare,
typename _Alloc>
1841#if __cplusplus >= 201103L
1842 template<
typename _Arg>
1844 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1845 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1846#if __cplusplus >= 201103L
1847 _M_insert_lower(_Base_ptr __p, _Arg&& __v)
1849 _M_insert_lower(_Base_ptr __p,
const _Val& __v)
1852 bool __insert_left = (__p == _M_end()
1853 || !_M_impl._M_key_compare(_S_key(__p),
1854 _KeyOfValue()(__v)));
1856 _Link_type __z = _M_create_node(_GLIBCXX_FORWARD(_Arg, __v));
1858 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
1859 this->_M_impl._M_header);
1860 ++_M_impl._M_node_count;
1861 return iterator(__z);
1864 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1865 typename _Compare,
typename _Alloc>
1866#if __cplusplus >= 201103L
1867 template<
typename _Arg>
1869 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
1870 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1871#if __cplusplus >= 201103L
1872 _M_insert_equal_lower(_Arg&& __v)
1874 _M_insert_equal_lower(
const _Val& __v)
1877 _Link_type __x = _M_begin();
1878 _Base_ptr __y = _M_end();
1882 __x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ?
1883 _S_left(__x) : _S_right(__x);
1885 return _M_insert_lower(__y, _GLIBCXX_FORWARD(_Arg, __v));
1888 template<
typename _Key,
typename _Val,
typename _KoV,
1889 typename _Compare,
typename _Alloc>
1890 template<
bool _MoveValues,
typename _NodeGen>
1891 typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type
1892 _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::
1893 _M_copy(_Link_type __x, _Base_ptr __p, _NodeGen& __node_gen)
1896 _Link_type __top = _M_clone_node<_MoveValues>(__x, __node_gen);
1897 __top->_M_parent = __p;
1903 _M_copy<_MoveValues>(_S_right(__x), __top, __node_gen);
1909 _Link_type __y = _M_clone_node<_MoveValues>(__x, __node_gen);
1911 __y->_M_parent = __p;
1913 __y->_M_right = _M_copy<_MoveValues>(_S_right(__x),
1922 __throw_exception_again;
1927 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1928 typename _Compare,
typename _Alloc>
1930 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1931 _M_erase(_Link_type __x)
1936 _M_erase(_S_right(__x));
1937 _Link_type __y = _S_left(__x);
1943 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1944 typename _Compare,
typename _Alloc>
1945 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1946 _Compare, _Alloc>::iterator
1947 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1948 _M_lower_bound(_Link_type __x, _Base_ptr __y,
1952 if (!_M_impl._M_key_compare(_S_key(__x), __k))
1953 __y = __x, __x = _S_left(__x);
1955 __x = _S_right(__x);
1956 return iterator(__y);
1959 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1960 typename _Compare,
typename _Alloc>
1961 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1962 _Compare, _Alloc>::const_iterator
1963 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1964 _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y,
1965 const _Key& __k)
const
1968 if (!_M_impl._M_key_compare(_S_key(__x), __k))
1969 __y = __x, __x = _S_left(__x);
1971 __x = _S_right(__x);
1972 return const_iterator(__y);
1975 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1976 typename _Compare,
typename _Alloc>
1977 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1978 _Compare, _Alloc>::iterator
1979 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1980 _M_upper_bound(_Link_type __x, _Base_ptr __y,
1984 if (_M_impl._M_key_compare(__k, _S_key(__x)))
1985 __y = __x, __x = _S_left(__x);
1987 __x = _S_right(__x);
1988 return iterator(__y);
1991 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
1992 typename _Compare,
typename _Alloc>
1993 typename _Rb_tree<_Key, _Val, _KeyOfValue,
1994 _Compare, _Alloc>::const_iterator
1995 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
1996 _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y,
1997 const _Key& __k)
const
2000 if (_M_impl._M_key_compare(__k, _S_key(__x)))
2001 __y = __x, __x = _S_left(__x);
2003 __x = _S_right(__x);
2004 return const_iterator(__y);
2007 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2008 typename _Compare,
typename _Alloc>
2009 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2010 _Compare, _Alloc>::iterator,
2011 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2012 _Compare, _Alloc>::iterator>
2013 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2014 equal_range(
const _Key& __k)
2016 _Link_type __x = _M_begin();
2017 _Base_ptr __y = _M_end();
2020 if (_M_impl._M_key_compare(_S_key(__x), __k))
2021 __x = _S_right(__x);
2022 else if (_M_impl._M_key_compare(__k, _S_key(__x)))
2023 __y = __x, __x = _S_left(__x);
2026 _Link_type __xu(__x);
2027 _Base_ptr __yu(__y);
2028 __y = __x, __x = _S_left(__x);
2029 __xu = _S_right(__xu);
2030 return pair<iterator,
2031 iterator>(_M_lower_bound(__x, __y, __k),
2032 _M_upper_bound(__xu, __yu, __k));
2035 return pair<iterator, iterator>(iterator(__y),
2039 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2040 typename _Compare,
typename _Alloc>
2041 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2042 _Compare, _Alloc>::const_iterator,
2043 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2044 _Compare, _Alloc>::const_iterator>
2045 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2046 equal_range(
const _Key& __k)
const
2048 _Const_Link_type __x = _M_begin();
2049 _Const_Base_ptr __y = _M_end();
2052 if (_M_impl._M_key_compare(_S_key(__x), __k))
2053 __x = _S_right(__x);
2054 else if (_M_impl._M_key_compare(__k, _S_key(__x)))
2055 __y = __x, __x = _S_left(__x);
2058 _Const_Link_type __xu(__x);
2059 _Const_Base_ptr __yu(__y);
2060 __y = __x, __x = _S_left(__x);
2061 __xu = _S_right(__xu);
2062 return pair<const_iterator,
2063 const_iterator>(_M_lower_bound(__x, __y, __k),
2064 _M_upper_bound(__xu, __yu, __k));
2067 return pair<const_iterator, const_iterator>(const_iterator(__y),
2068 const_iterator(__y));
2071 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2072 typename _Compare,
typename _Alloc>
2074 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2076 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
2080 if (__t._M_root() != 0)
2081 _M_impl._M_move_data(__t._M_impl);
2083 else if (__t._M_root() == 0)
2084 __t._M_impl._M_move_data(_M_impl);
2088 std::swap(_M_leftmost(),__t._M_leftmost());
2089 std::swap(_M_rightmost(),__t._M_rightmost());
2091 _M_root()->_M_parent = _M_end();
2092 __t._M_root()->_M_parent = __t._M_end();
2093 std::swap(this->_M_impl._M_node_count, __t._M_impl._M_node_count);
2096 std::swap(this->_M_impl._M_key_compare, __t._M_impl._M_key_compare);
2098 _Alloc_traits::_S_on_swap(_M_get_Node_allocator(),
2099 __t._M_get_Node_allocator());
2102 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2103 typename _Compare,
typename _Alloc>
2104 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2105 _Compare, _Alloc>::_Base_ptr,
2106 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2107 _Compare, _Alloc>::_Base_ptr>
2108 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2109 _M_get_insert_unique_pos(
const key_type& __k)
2111 typedef pair<_Base_ptr, _Base_ptr> _Res;
2112 _Link_type __x = _M_begin();
2113 _Base_ptr __y = _M_end();
2118 __comp = _M_impl._M_key_compare(__k, _S_key(__x));
2119 __x = __comp ? _S_left(__x) : _S_right(__x);
2121 iterator __j = iterator(__y);
2125 return _Res(__x, __y);
2129 if (_M_impl._M_key_compare(_S_key(__j._M_node), __k))
2130 return _Res(__x, __y);
2131 return _Res(__j._M_node, 0);
2134 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2135 typename _Compare,
typename _Alloc>
2136 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2137 _Compare, _Alloc>::_Base_ptr,
2138 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2139 _Compare, _Alloc>::_Base_ptr>
2140 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2141 _M_get_insert_equal_pos(
const key_type& __k)
2143 typedef pair<_Base_ptr, _Base_ptr> _Res;
2144 _Link_type __x = _M_begin();
2145 _Base_ptr __y = _M_end();
2149 __x = _M_impl._M_key_compare(__k, _S_key(__x)) ?
2150 _S_left(__x) : _S_right(__x);
2152 return _Res(__x, __y);
2155 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2156 typename _Compare,
typename _Alloc>
2157#if __cplusplus >= 201103L
2158 template<
typename _Arg>
2160 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2161 _Compare, _Alloc>::iterator,
bool>
2162 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2163#if __cplusplus >= 201103L
2164 _M_insert_unique(_Arg&& __v)
2166 _M_insert_unique(
const _Val& __v)
2169 typedef pair<iterator, bool> _Res;
2170 pair<_Base_ptr, _Base_ptr> __res
2171 = _M_get_insert_unique_pos(_KeyOfValue()(__v));
2175 _Alloc_node __an(*
this);
2176 return _Res(_M_insert_(__res.first, __res.second,
2177 _GLIBCXX_FORWARD(_Arg, __v), __an),
2181 return _Res(iterator(__res.first),
false);
2184 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2185 typename _Compare,
typename _Alloc>
2186#if __cplusplus >= 201103L
2187 template<
typename _Arg>
2189 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2190 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2191#if __cplusplus >= 201103L
2192 _M_insert_equal(_Arg&& __v)
2194 _M_insert_equal(
const _Val& __v)
2197 pair<_Base_ptr, _Base_ptr> __res
2198 = _M_get_insert_equal_pos(_KeyOfValue()(__v));
2199 _Alloc_node __an(*
this);
2200 return _M_insert_(__res.first, __res.second,
2201 _GLIBCXX_FORWARD(_Arg, __v), __an);
2204 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2205 typename _Compare,
typename _Alloc>
2206 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2207 _Compare, _Alloc>::_Base_ptr,
2208 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2209 _Compare, _Alloc>::_Base_ptr>
2210 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2211 _M_get_insert_hint_unique_pos(const_iterator __position,
2212 const key_type& __k)
2214 iterator __pos = __position._M_const_cast();
2215 typedef pair<_Base_ptr, _Base_ptr> _Res;
2218 if (__pos._M_node == _M_end())
2221 && _M_impl._M_key_compare(_S_key(_M_rightmost()), __k))
2222 return _Res(0, _M_rightmost());
2224 return _M_get_insert_unique_pos(__k);
2226 else if (_M_impl._M_key_compare(__k, _S_key(__pos._M_node)))
2229 iterator __before = __pos;
2230 if (__pos._M_node == _M_leftmost())
2231 return _Res(_M_leftmost(), _M_leftmost());
2232 else if (_M_impl._M_key_compare(_S_key((--__before)._M_node), __k))
2234 if (_S_right(__before._M_node) == 0)
2235 return _Res(0, __before._M_node);
2237 return _Res(__pos._M_node, __pos._M_node);
2240 return _M_get_insert_unique_pos(__k);
2242 else if (_M_impl._M_key_compare(_S_key(__pos._M_node), __k))
2245 iterator __after = __pos;
2246 if (__pos._M_node == _M_rightmost())
2247 return _Res(0, _M_rightmost());
2248 else if (_M_impl._M_key_compare(__k, _S_key((++__after)._M_node)))
2250 if (_S_right(__pos._M_node) == 0)
2251 return _Res(0, __pos._M_node);
2253 return _Res(__after._M_node, __after._M_node);
2256 return _M_get_insert_unique_pos(__k);
2260 return _Res(__pos._M_node, 0);
2263 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2264 typename _Compare,
typename _Alloc>
2265#if __cplusplus >= 201103L
2266 template<
typename _Arg,
typename _NodeGen>
2268 template<
typename _NodeGen>
2270 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2271 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2272 _M_insert_unique_(const_iterator __position,
2273#
if __cplusplus >= 201103L
2278 _NodeGen& __node_gen)
2280 pair<_Base_ptr, _Base_ptr> __res
2281 = _M_get_insert_hint_unique_pos(__position, _KeyOfValue()(__v));
2284 return _M_insert_(__res.first, __res.second,
2285 _GLIBCXX_FORWARD(_Arg, __v),
2287 return iterator(__res.first);
2290 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2291 typename _Compare,
typename _Alloc>
2292 pair<
typename _Rb_tree<_Key, _Val, _KeyOfValue,
2293 _Compare, _Alloc>::_Base_ptr,
2294 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2295 _Compare, _Alloc>::_Base_ptr>
2296 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2297 _M_get_insert_hint_equal_pos(const_iterator __position,
const key_type& __k)
2299 iterator __pos = __position._M_const_cast();
2300 typedef pair<_Base_ptr, _Base_ptr> _Res;
2303 if (__pos._M_node == _M_end())
2306 && !_M_impl._M_key_compare(__k, _S_key(_M_rightmost())))
2307 return _Res(0, _M_rightmost());
2309 return _M_get_insert_equal_pos(__k);
2311 else if (!_M_impl._M_key_compare(_S_key(__pos._M_node), __k))
2314 iterator __before = __pos;
2315 if (__pos._M_node == _M_leftmost())
2316 return _Res(_M_leftmost(), _M_leftmost());
2317 else if (!_M_impl._M_key_compare(__k, _S_key((--__before)._M_node)))
2319 if (_S_right(__before._M_node) == 0)
2320 return _Res(0, __before._M_node);
2322 return _Res(__pos._M_node, __pos._M_node);
2325 return _M_get_insert_equal_pos(__k);
2330 iterator __after = __pos;
2331 if (__pos._M_node == _M_rightmost())
2332 return _Res(0, _M_rightmost());
2333 else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node), __k))
2335 if (_S_right(__pos._M_node) == 0)
2336 return _Res(0, __pos._M_node);
2338 return _Res(__after._M_node, __after._M_node);
2345 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2346 typename _Compare,
typename _Alloc>
2347#if __cplusplus >= 201103L
2348 template<
typename _Arg,
typename _NodeGen>
2350 template<
typename _NodeGen>
2352 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
2353 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2354 _M_insert_equal_(const_iterator __position,
2355#
if __cplusplus >= 201103L
2360 _NodeGen& __node_gen)
2362 pair<_Base_ptr, _Base_ptr> __res
2363 = _M_get_insert_hint_equal_pos(__position, _KeyOfValue()(__v));
2366 return _M_insert_(__res.first, __res.second,
2367 _GLIBCXX_FORWARD(_Arg, __v),
2370 return _M_insert_equal_lower(_GLIBCXX_FORWARD(_Arg, __v));
2373#if __cplusplus >= 201103L
2374 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2375 typename _Compare,
typename _Alloc>
2377 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2378 _M_insert_node(_Base_ptr __x, _Base_ptr __p, _Link_type __z)
2381 bool __insert_left = (__x != 0 || __p == _M_end()
2382 || _M_impl._M_key_compare(_S_key(__z),
2385 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
2386 this->_M_impl._M_header);
2387 ++_M_impl._M_node_count;
2388 return iterator(__z);
2391 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2392 typename _Compare,
typename _Alloc>
2394 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2395 _M_insert_lower_node(_Base_ptr __p, _Link_type __z)
2398 bool __insert_left = (__p == _M_end()
2399 || !_M_impl._M_key_compare(_S_key(__p),
2402 _Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
2403 this->_M_impl._M_header);
2404 ++_M_impl._M_node_count;
2405 return iterator(__z);
2408 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2409 typename _Compare,
typename _Alloc>
2411 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2412 _M_insert_equal_lower_node(_Link_type __z)
2415 _Link_type __x = _M_begin();
2416 _Base_ptr __y = _M_end();
2420 __x = !_M_impl._M_key_compare(_S_key(__x), _S_key(__z)) ?
2421 _S_left(__x) : _S_right(__x);
2423 return _M_insert_lower_node(__y, __z);
2426 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2427 typename _Compare,
typename _Alloc>
2428 template<
typename... _Args>
2430 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2431 _M_emplace_unique(_Args&&... __args)
2432 -> pair<iterator, bool>
2434 _Auto_node __z(*
this, std::forward<_Args>(__args)...);
2435 auto __res = _M_get_insert_unique_pos(__z._M_key());
2437 return {__z._M_insert(__res),
true};
2438 return {iterator(__res.first),
false};
2441 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2442 typename _Compare,
typename _Alloc>
2443 template<
typename... _Args>
2445 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2446 _M_emplace_equal(_Args&&... __args)
2449 _Auto_node __z(*
this, std::forward<_Args>(__args)...);
2450 auto __res = _M_get_insert_equal_pos(__z._M_key());
2451 return __z._M_insert(__res);
2454 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2455 typename _Compare,
typename _Alloc>
2456 template<
typename... _Args>
2458 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2459 _M_emplace_hint_unique(const_iterator __pos, _Args&&... __args)
2462 _Auto_node __z(*
this, std::forward<_Args>(__args)...);
2463 auto __res = _M_get_insert_hint_unique_pos(__pos, __z._M_key());
2465 return __z._M_insert(__res);
2466 return iterator(__res.first);
2469 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2470 typename _Compare,
typename _Alloc>
2471 template<
typename... _Args>
2473 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2474 _M_emplace_hint_equal(const_iterator __pos, _Args&&... __args)
2477 _Auto_node __z(*
this, std::forward<_Args>(__args)...);
2478 auto __res = _M_get_insert_hint_equal_pos(__pos, __z._M_key());
2480 return __z._M_insert(__res);
2481 return __z._M_insert_equal_lower();
2486 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2487 typename _Compare,
typename _Alloc>
2489 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2490 _M_erase_aux(const_iterator __position)
2493 static_cast<_Link_type
>(_Rb_tree_rebalance_for_erase
2494 (
const_cast<_Base_ptr
>(__position._M_node),
2495 this->_M_impl._M_header));
2497 --_M_impl._M_node_count;
2500 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2501 typename _Compare,
typename _Alloc>
2503 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2504 _M_erase_aux(const_iterator __first, const_iterator __last)
2506 if (__first ==
begin() && __last ==
end())
2509 while (__first != __last)
2510 _M_erase_aux(__first++);
2513 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2514 typename _Compare,
typename _Alloc>
2515 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
2516 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2517 erase(
const _Key& __x)
2519 pair<iterator, iterator> __p = equal_range(__x);
2520 const size_type __old_size =
size();
2521 _M_erase_aux(__p.first, __p.second);
2522 return __old_size -
size();
2525 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2526 typename _Compare,
typename _Alloc>
2527 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2528 _Compare, _Alloc>::iterator
2529 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2530 find(
const _Key& __k)
2532 iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
2533 return (__j ==
end()
2534 || _M_impl._M_key_compare(__k,
2535 _S_key(__j._M_node))) ?
end() : __j;
2538 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2539 typename _Compare,
typename _Alloc>
2540 typename _Rb_tree<_Key, _Val, _KeyOfValue,
2541 _Compare, _Alloc>::const_iterator
2542 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2543 find(
const _Key& __k)
const
2545 const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
2546 return (__j ==
end()
2547 || _M_impl._M_key_compare(__k,
2548 _S_key(__j._M_node))) ?
end() : __j;
2551 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2552 typename _Compare,
typename _Alloc>
2553 typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type
2554 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
2555 count(
const _Key& __k)
const
2557 pair<const_iterator, const_iterator> __p = equal_range(__k);
2562 _GLIBCXX_PURE
unsigned int
2563 _Rb_tree_black_count(
const _Rb_tree_node_base* __node,
2564 const _Rb_tree_node_base* __root)
throw ();
2566 template<
typename _Key,
typename _Val,
typename _KeyOfValue,
2567 typename _Compare,
typename _Alloc>
2569 _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::__rb_verify()
const
2571 if (_M_impl._M_node_count == 0 ||
begin() ==
end())
2572 return _M_impl._M_node_count == 0 &&
begin() ==
end()
2573 && this->_M_impl._M_header._M_left == _M_end()
2574 && this->_M_impl._M_header._M_right == _M_end();
2576 unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root());
2577 for (const_iterator __it =
begin(); __it !=
end(); ++__it)
2579 _Const_Link_type __x =
static_cast<_Const_Link_type
>(__it._M_node);
2580 _Const_Link_type __L = _S_left(__x);
2581 _Const_Link_type __R = _S_right(__x);
2583 if (__x->_M_color == _S_red)
2584 if ((__L && __L->_M_color == _S_red)
2585 || (__R && __R->_M_color == _S_red))
2588 if (__L && _M_impl._M_key_compare(_S_key(__x), _S_key(__L)))
2590 if (__R && _M_impl._M_key_compare(_S_key(__R), _S_key(__x)))
2593 if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len)
2597 if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root()))
2599 if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root()))
2604#if __cplusplus > 201402L
2606 template<
typename _Key,
typename _Val,
typename _Sel,
typename _Cmp1,
2607 typename _Alloc,
typename _Cmp2>
2608 struct _Rb_tree_merge_helper<_Rb_tree<_Key, _Val, _Sel, _Cmp1, _Alloc>,
2612 friend class _Rb_tree<_Key, _Val, _Sel, _Cmp1, _Alloc>;
2615 _S_get_impl(_Rb_tree<_Key, _Val, _Sel, _Cmp2, _Alloc>& __tree)
2616 {
return __tree._M_impl; }
2620_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.
typename __detected_or_t< is_empty< _Alloc >, __equal, _Alloc >::type 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.