1#ifndef NEFORCE_CORE_CONTAINER_RB_TREE_HPP__
2#define NEFORCE_CORE_CONTAINER_RB_TREE_HPP__
20NEFORCE_BEGIN_NAMESPACE__
104 while (root->left_ !=
nullptr) {
116 while (root->right_ !=
nullptr) {
134 if (y->
left_ !=
nullptr) {
142 }
else if (axis == axis->parent_->left_) {
143 axis->parent_->left_ = y;
145 axis->parent_->right_ = y;
162 if (y->
right_ !=
nullptr) {
169 }
else if (axis == axis->parent_->right_) {
170 axis->parent_->right_ = y;
172 axis->parent_->left_ = y;
190 while (insert != root && insert->parent_->color_ ==
RB_TREE_RED) {
191 if (insert->parent_ == insert->parent_->parent_->left_) {
198 insert = insert->parent_->parent_;
200 if (insert == insert->parent_->right_) {
201 insert = insert->parent_;
214 insert = insert->parent_->parent_;
216 if (insert == insert->parent_->left_) {
217 insert = insert->parent_;
247 if (y->
left_ ==
nullptr) {
250 if (y->
right_ ==
nullptr) {
254 while (y->
left_ !=
nullptr) {
262 erase->left_->parent_ = y;
265 if (y !=
erase->right_) {
273 erase->right_->parent_ = y;
281 erase->parent_->left_ = y;
283 erase->parent_->right_ = y;
299 erase->parent_->left_ = x;
301 erase->parent_->right_ = x;
305 if (leftmost ==
erase) {
306 if (
erase->right_ ==
nullptr) {
307 leftmost =
erase->parent_;
313 if (rightmost ==
erase) {
314 if (
erase->left_ ==
nullptr) {
315 rightmost =
erase->parent_;
324 if (x == x_parent->
left_) {
347 if (w->
left_ !=
nullptr) {
356 if (w->
right_ !=
nullptr) {
385 if (w->
right_ !=
nullptr) {
395 if (w->
left_ !=
nullptr) {
451 if (
node_->right_ !=
nullptr) {
453 while (
node_->left_ !=
nullptr) {
462 if (
node_->right_ != y) {
474 }
else if (
node_->left_ !=
nullptr) {
476 while (y->
right_ !=
nullptr) {
500template <
bool IsConst,
typename RbTree>
509 typename container_type::reference>;
511 typename container_type::pointer>;
516 using link_type = node_type*;
520 template <
typename,
typename,
typename,
typename,
typename>
521 friend class rb_tree;
524 rb_tree_iterator() noexcept = default;
525 ~rb_tree_iterator() = default;
527 rb_tree_iterator(const rb_tree_iterator&) noexcept = default;
528 rb_tree_iterator& operator=(const rb_tree_iterator&) noexcept = default;
529 rb_tree_iterator(rb_tree_iterator&&) noexcept = default;
530 rb_tree_iterator& operator=(rb_tree_iterator&&) noexcept = default;
548 link_type link = link_type(
node_);
550 "Attempting to dereference out of boundary");
577 NEFORCE_NODISCARD
bool equal(
const rb_tree_iterator& rhs)
const noexcept {
578 NEFORCE_DEBUG_VERIFY(container_ == rhs.container_,
"Attempting to equal to a different container");
579 return node_ == rhs.node_;
607template <
typename Key,
typename Value,
typename KeyOfValue,
typename Compare,
634 using base_ptr = base_node*;
635 using link_type = link_node*;
637 link_type header_ =
nullptr;
638 Compare key_compare_{};
639 KeyOfValue extracter_{};
640 compressed_pair<allocator_type, size_t> size_pair_{default_construct_tag{}, 0};
642 template <
bool,
typename>
643 friend struct rb_tree_iterator;
650 bool released_ =
false;
653 node_guard(
rb_tree* t, link_type n) noexcept :
659 tree_->destroy_node(node_);
663 link_type release() noexcept {
673 link_type& root() const noexcept {
return reinterpret_cast<link_type&
>(header_->parent_); }
679 link_type& leftmost() const noexcept {
return reinterpret_cast<link_type&
>(header_->left_); }
685 link_type& rightmost() const noexcept {
return reinterpret_cast<link_type&
>(header_->right_); }
692 static link_type& left(link_type ptr)
noexcept {
return reinterpret_cast<link_type&
>(ptr->left_); }
699 static link_type& right(link_type ptr)
noexcept {
return reinterpret_cast<link_type&
>(ptr->right_); }
706 static link_type& parent(link_type ptr)
noexcept {
return reinterpret_cast<link_type&
>(ptr->parent_); }
713 static const Key& key(link_type ptr)
noexcept {
return KeyOfValue()(ptr->data); }
720 static const Key& key(base_ptr ptr)
noexcept {
return rb_tree::key(
reinterpret_cast<link_type
>(ptr)); }
727 static link_type minimum(link_type ptr)
noexcept {
return static_cast<link_type
>(
base_node::minimum(ptr)); }
734 static link_type maximum(link_type ptr)
noexcept {
return static_cast<link_type
>(
base_node::maximum(ptr)); }
742 template <
typename... Args>
743 link_type create_node(Args&&... args) {
744 link_type tmp = size_pair_.get_base().allocate();
748 rb_tree::destroy_node(tmp);
759 link_type copy_node(link_type ptr) {
760 link_type tmp = rb_tree::create_node(ptr->data);
761 tmp->color_ = ptr->color_;
762 tmp->left_ =
nullptr;
763 tmp->right_ =
nullptr;
772 if (ptr ==
nullptr) {
776 size_pair_.get_base().deallocate(ptr);
786 iterator insert_into(base_ptr child, base_ptr parent, link_type ptr) {
787 auto x =
static_cast<link_type
>(child);
788 auto y =
static_cast<link_type
>(parent);
789 if (y == header_ || x !=
nullptr || key_compare_(rb_tree::key(ptr), rb_tree::key(y))) {
790 rb_tree::left(y) = ptr;
795 }
else if (y == leftmost()) {
799 rb_tree::right(y) = ptr;
800 if (y == rightmost()) {
804 rb_tree::parent(ptr) = y;
805 rb_tree::left(ptr) =
nullptr;
806 rb_tree::right(ptr) =
nullptr;
818 link_type copy_under(link_type src_root, link_type parent) {
819 link_type top = rb_tree::copy_node(src_root);
820 top->parent_ = parent;
822 if (src_root->right_ !=
nullptr) {
823 top->right_ = rb_tree::copy_under(rb_tree::right(src_root), top);
826 src_root = rb_tree::left(src_root);
827 while (src_root !=
nullptr) {
828 link_type y = rb_tree::copy_node(src_root);
831 if (src_root->right_ !=
nullptr) {
832 y->right_ = rb_tree::copy_under(rb_tree::right(src_root), y);
835 src_root = rb_tree::left(src_root);
838 rb_tree::erase_under(top);
849 if (root ==
nullptr) {
852 rb_tree::erase_under(rb_tree::right(root));
853 rb_tree::erase_under(rb_tree::left(root));
854 rb_tree::destroy_node(root);
861 header_ = size_pair_.get_base().allocate(1);
864 leftmost() = header_;
865 rightmost() = header_;
872 void copy_from(
const rb_tree& other) {
873 if (other.root() ==
nullptr) {
875 leftmost() = header_;
876 rightmost() = header_;
879 root() = rb_tree::copy_under(other.root(), header_);
881 size_pair_.get_base().deallocate(header_);
885 leftmost() = rb_tree::minimum(root());
886 rightmost() = rb_tree::maximum(root());
888 size_pair_.value = other.size_pair_.
value;
896 pair<iterator, bool> insert_unique(link_type node) {
897 link_type y = header_;
898 link_type x = root();
900 while (x !=
nullptr) {
902 comp = key_compare_(rb_tree::key(node), rb_tree::key(x));
903 x = comp ? rb_tree::left(x) :
rb_tree::right(x);
909 return pair<iterator, bool>(rb_tree::insert_into(x, y, node),
true);
914 if (key_compare_(rb_tree::key(link_type(j.node_)), rb_tree::key(node))) {
915 return pair<iterator, bool>(rb_tree::insert_into(x, y, node),
true);
917 rb_tree::destroy_node(node);
918 return pair<iterator, bool>(j,
false);
926 iterator insert_equal(link_type node) {
927 link_type y = header_;
928 link_type x = root();
929 while (x !=
nullptr) {
931 x = key_compare_(rb_tree::key(node), rb_tree::key(x)) ? rb_tree::left(x) :
rb_tree::right(x);
933 return rb_tree::insert_into(x, y, node);
956 key_compare_(other.key_compare_),
957 extracter_(other.extracter_),
958 size_pair_(other.size_pair_) {
960 rb_tree::copy_from(other);
984 header_(_NEFORCE
move(other.header_)),
985 key_compare_(_NEFORCE
move(other.key_compare_)),
986 extracter_(_NEFORCE
move(other.extracter_)),
987 size_pair_(_NEFORCE
move(other.size_pair_)) {
988 other.header_ =
nullptr;
989 other.size_pair_.
value = 0;
1012 size_pair_.get_base().deallocate(header_);
1104 NEFORCE_NODISCARD
bool empty() const noexcept {
return size_pair_.value == 0; }
1111 return key_compare_;
1120 template <
typename... Args>
1122 const link_type tmp = rb_tree::create_node(_NEFORCE
forward<Args>(args)...);
1123 return rb_tree::insert_unique(tmp);
1147 template <
typename... Args>
1149 link_type tmp = rb_tree::create_node(_NEFORCE
forward<Args>(args)...);
1150 node_guard guard(
this, tmp);
1153 if (
size() > 0 && key_compare_(rb_tree::key(tmp), rb_tree::key(position.
node_))) {
1155 return rb_tree::insert_into(position.
node_, position.
node_, tmp);
1158 return rb_tree::insert_unique(tmp).first;
1161 if (position.
node_ == header_) {
1162 if (key_compare_(rb_tree::key(rightmost()), rb_tree::key(tmp))) {
1164 return rb_tree::insert_into(
nullptr, rightmost(), tmp);
1167 return rb_tree::insert_unique(tmp).first;
1173 if (key_compare_(rb_tree::key(before.
node_), rb_tree::key(tmp)) &&
1174 key_compare_(rb_tree::key(tmp), rb_tree::key(position.
node_))) {
1175 if (rb_tree::right(link_type(before.
node_)) ==
nullptr) {
1177 return rb_tree::insert_into(
nullptr, before.
node_, tmp);
1179 if (rb_tree::left(link_type(position.
node_)) ==
nullptr) {
1181 return rb_tree::insert_into(position.
node_, position.
node_, tmp);
1186 return rb_tree::insert_unique(tmp).first;
1215 template <
typename Iterator, enable_if_t<is_iter_v<Iterator>,
int> = 0>
1217 for (; first != last; ++first) {
1218 rb_tree::insert_unique(*first);
1228 template <
typename... Args>
1230 const link_type tmp = rb_tree::create_node(_NEFORCE
forward<Args>(args)...);
1231 return rb_tree::insert_equal(tmp);
1255 template <
typename... Args>
1257 link_type tmp = rb_tree::create_node(_NEFORCE
forward<Args>(args)...);
1258 node_guard guard(
this, tmp);
1261 if (
size() > 0 && key_compare_(rb_tree::key(tmp), rb_tree::key(position.
node_))) {
1263 return rb_tree::insert_into(position.
node_, position.
node_, tmp);
1266 return rb_tree::insert_equal(tmp);
1269 if (position.
node_ == header_) {
1270 if (!key_compare_(rb_tree::key(tmp), rb_tree::key(rightmost()))) {
1272 return rb_tree::insert_into(
nullptr, rightmost(), tmp);
1275 return rb_tree::insert_equal(tmp);
1281 if (!key_compare_(rb_tree::key(tmp), rb_tree::key(before.
node_)) &&
1282 !key_compare_(rb_tree::key(position.
node_), rb_tree::key(tmp))) {
1283 if (rb_tree::right(link_type(before.
node_)) ==
nullptr) {
1285 return rb_tree::insert_into(
nullptr, before.
node_, tmp);
1288 return rb_tree::insert_into(position.
node_, position.
node_, tmp);
1292 return rb_tree::insert_equal(tmp);
1321 template <
typename Iterator, enable_if_t<is_iter_v<Iterator>,
int> = 0>
1323 for (; first != last; ++first) {
1324 rb_tree::insert_equal(*first);
1345 auto y =
reinterpret_cast<link_type
>(
1347 rb_tree::destroy_node(y);
1357 if (first ==
begin() && last ==
end()) {
1360 while (first != last) {
1370 if (header_ ==
nullptr) {
1373 if (size_pair_.value == 0) {
1376 rb_tree::erase_under(root());
1377 leftmost() = header_;
1379 rightmost() = header_;
1380 size_pair_.value = 0;
1389 link_type y = header_;
1390 link_type x = root();
1392 while (x !=
nullptr) {
1393 if (!key_compare_(rb_tree::key(x), key)) {
1395 x = rb_tree::left(x);
1397 x = rb_tree::right(x);
1405 return key_compare_(key, rb_tree::key(y)) ?
end() : j;
1414 link_type y = header_;
1415 link_type x = root();
1417 while (x !=
nullptr) {
1418 if (!key_compare_(rb_tree::key(x), key)) {
1420 x = rb_tree::left(x);
1422 x = rb_tree::right(x);
1430 return key_compare_(key, rb_tree::key(y)) ?
cend() : j;
1450 link_type y = header_;
1451 link_type x = root();
1453 while (x !=
nullptr) {
1454 if (!key_compare_(rb_tree::key(x), key)) {
1456 x = rb_tree::left(x);
1458 x = rb_tree::right(x);
1471 link_type y = header_;
1472 link_type x = root();
1474 while (x !=
nullptr) {
1475 if (!key_compare_(rb_tree::key(x), key)) {
1477 x = rb_tree::left(x);
1479 x = rb_tree::right(x);
1492 link_type y = header_;
1493 link_type x = root();
1495 while (x !=
nullptr) {
1496 if (key_compare_(key, rb_tree::key(x))) {
1498 x = rb_tree::left(x);
1500 x = rb_tree::right(x);
1513 link_type y = header_;
1514 link_type x = root();
1516 while (x !=
nullptr) {
1517 if (key_compare_(key, rb_tree::key(x))) {
1519 x = rb_tree::left(x);
1521 x = rb_tree::right(x);
1552 _NEFORCE
swap(header_, other.header_);
1553 _NEFORCE
swap(size_pair_, other.size_pair_);
1554 _NEFORCE
swap(key_compare_, other.key_compare_);
1555 _NEFORCE
swap(extracter_, other.extracter_);
1581NEFORCE_END_NAMESPACE__
NEFORCE_NODISCARD bool empty() const noexcept
检查是否为空
void erase(iterator first, iterator last) noexcept(is_nothrow_destructible_v< link_node >)
删除指定范围内的元素
NEFORCE_NODISCARD iterator upper_bound(const key_type &key)
获取第一个大于指定键的元素位置
iterator emplace_equal(Args &&... args)
在树中构造元素(允许重复键版本)
NEFORCE_NODISCARD bool operator==(const rb_tree &rhs) const noexcept(noexcept(_NEFORCE equal(cbegin(), cend(), rhs.cbegin())))
相等比较操作符
NEFORCE_NODISCARD pair< iterator, iterator > equal_range(const key_type &key)
获取等于指定键的元素范围
NEFORCE_NODISCARD const_iterator end() const noexcept
获取常量结束迭代器
NEFORCE_NODISCARD iterator lower_bound(const key_type &key)
获取第一个不小于指定键的元素位置
_NEFORCE reverse_iterator< const_iterator > const_reverse_iterator
NEFORCE_NODISCARD const_iterator find(const key_type &key) const
查找具有指定键的元素(常量版本)
iterator insert_equal(value_type &&value)
移动插入元素(允许重复键版本)
iterator insert_unique(iterator position, const value_type &value)
在提示位置附近插入元素(唯一键版本)
rb_tree(rb_tree &&other) noexcept(is_nothrow_move_constructible_v< Compare > &&is_nothrow_move_constructible_v< KeyOfValue > &&is_nothrow_move_constructible_v< allocator_type >)
移动构造函数
NEFORCE_NODISCARD size_type size() const noexcept
获取元素数量
const pair< const Key, T > & const_reference
iterator insert_equal(iterator position, const value_type &value)
在提示位置附近插入元素(允许重复键版本)
NEFORCE_NODISCARD size_type count(const key_type &key) const
统计具有指定键的元素数量
iterator insert_equal(iterator position, value_type &&value)
在提示位置附近移动插入元素(允许重复键版本)
_NEFORCE reverse_iterator< iterator > reverse_iterator
void insert_equal(Iterator first, Iterator last)
范围插入元素(允许重复键版本)
iterator emplace_unique_hint(iterator position, Args &&... args)
在提示位置附近构造元素(唯一键版本)
pair< const Key, T > value_type
NEFORCE_NODISCARD const_reverse_iterator crbegin() const noexcept
获取常量反向起始迭代器
rb_tree_iterator< true, rb_tree > const_iterator
NEFORCE_NODISCARD iterator begin() noexcept
获取起始迭代器
NEFORCE_NODISCARD reverse_iterator rbegin() noexcept
获取反向起始迭代器
NEFORCE_NODISCARD const_iterator cbegin() const noexcept
获取常量起始迭代器
NEFORCE_NODISCARD iterator find(const key_type &key)
查找具有指定键的元素
ptrdiff_t difference_type
NEFORCE_NODISCARD iterator end() noexcept
获取结束迭代器
pair< iterator, bool > insert_unique(const value_type &value)
插入元素(唯一键版本)
iterator insert_equal(const value_type &value)
插入元素(允许重复键版本)
NEFORCE_NODISCARD const_reverse_iterator rbegin() const noexcept
获取常量反向起始迭代器
pair< iterator, bool > emplace_unique(Args &&... args)
在树中构造元素(唯一键版本)
size_type erase(const key_type &key) noexcept(is_nothrow_destructible_v< link_node >)
删除所有具有指定键的元素
NEFORCE_NODISCARD reverse_iterator rend() noexcept
获取反向结束迭代器
void erase(iterator position) noexcept(is_nothrow_destructible_v< link_node >)
删除指定位置的元素
NEFORCE_NODISCARD Compare key_compare() const noexcept(is_nothrow_copy_constructible_v< Compare >)
获取键比较函数对象
NEFORCE_NODISCARD const_reverse_iterator crend() const noexcept
获取常量反向结束迭代器
iterator emplace_equal_hint(iterator position, Args &&... args)
在提示位置附近构造元素(允许重复键版本)
rb_tree & operator=(rb_tree &&other) noexcept(is_nothrow_move_constructible_v< rb_tree >)
移动赋值运算符
void insert_unique(Iterator first, Iterator last)
范围插入元素(唯一键版本)
NEFORCE_NODISCARD const_iterator begin() const noexcept
获取常量起始迭代器
NEFORCE_NODISCARD const_iterator lower_bound(const key_type &key) const
获取第一个不小于指定键的元素位置(常量版本)
rb_tree_iterator< false, rb_tree > iterator
void clear() noexcept(is_nothrow_destructible_v< link_node >)
清空树
rb_tree(const rb_tree &other)
拷贝构造函数
pair< iterator, bool > insert_unique(value_type &&value)
移动插入元素(唯一键版本)
const pair< const Key, T > * const_pointer
pair< const Key, T > & reference
NEFORCE_NODISCARD const_reverse_iterator rend() const noexcept
获取常量反向结束迭代器
NEFORCE_NODISCARD const_iterator cend() const noexcept
获取常量结束迭代器
NEFORCE_NODISCARD pair< const_iterator, const_iterator > equal_range(const key_type &key) const
获取等于指定键的元素范围(常量版本)
void swap(rb_tree &other) noexcept(is_nothrow_swappable_v< Compare > &&is_nothrow_swappable_v< KeyOfValue > &&is_nothrow_swappable_v< allocator_type >)
交换两个红黑树的内容
pair< const Key, T > * pointer
rb_tree & operator=(const rb_tree &other)
拷贝赋值运算符
NEFORCE_NODISCARD size_type max_size() const noexcept
获取最大可能大小
iterator insert_unique(iterator position, value_type &&value)
在提示位置附近移动插入元素(唯一键版本)
NEFORCE_NODISCARD const_iterator upper_bound(const key_type &key) const
获取第一个大于指定键的元素位置(常量版本)
NEFORCE_NODISCARD bool operator<(const rb_tree &rhs) const noexcept(noexcept(_NEFORCE lexicographical_compare(cbegin(), cend(), rhs.cbegin(), rhs.cend())))
小于比较操作符
rb_tree(const Compare &comp)
构造函数,指定比较函数
NEFORCE_NODISCARD constexpr T * addressof(T &x) noexcept
获取对象的地址
NEFORCE_NODISCARD constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
NEFORCE_INLINE17 constexpr bool is_object_v
is_object的便捷变量模板
NEFORCE_NODISCARD constexpr bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2, BinaryPredicate binary_pred) noexcept(noexcept(++first1) &&noexcept(++first2) &&noexcept(binary_pred(*first1, *first2)))
比较两个范围是否相等
NEFORCE_NODISCARD constexpr bool lexicographical_compare(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, Compare comp) noexcept(noexcept(++first1) &&noexcept(++first2) &&noexcept(comp(*first1, *first2)) &&noexcept(first1==last1 &&first2 !=last2))
字典序比较两个范围
#define NEFORCE_DEBUG_VERIFY(CON, MESG)
调试模式断言
NEFORCE_CONSTEXPR20 T * construct(T *ptr, Args &&... args) noexcept(is_nothrow_constructible_v< T, Args... >)
在指定内存位置构造对象
NEFORCE_CONSTEXPR20 void destroy(T *pointer) noexcept(is_nothrow_destructible_v< T >)
销毁单个对象
constexpr iter_difference_t< Iterator > distance(Iterator first, Iterator last)
计算两个迭代器之间的距离
standard_allocator< T > allocator
标准分配器别名
NEFORCE_INLINE17 constexpr bool RB_TREE_RED
红黑树节点颜色常量:红色
NEFORCE_ALWAYS_INLINE_INLINE rb_tree_node_base * rb_tree_erase_rebalance(rb_tree_node_base *erase, rb_tree_node_base *&root, rb_tree_node_base *&leftmost, rb_tree_node_base *&rightmost) noexcept
删除节点后重新平衡红黑树
NEFORCE_ALWAYS_INLINE_INLINE void rb_tree_rotate_right(rb_tree_node_base *axis, rb_tree_node_base *&root) noexcept
红黑树右旋转
NEFORCE_ALWAYS_INLINE_INLINE void rb_tree_insert_rebalance(rb_tree_node_base *insert, rb_tree_node_base *&root) noexcept
插入节点后重新平衡红黑树
NEFORCE_INLINE17 constexpr bool RB_TREE_BLACK
红黑树节点颜色常量:黑色
NEFORCE_ALWAYS_INLINE_INLINE void rb_tree_rotate_left(rb_tree_node_base *axis, rb_tree_node_base *&root) noexcept
红黑树左旋转
constexpr size_t erase(Container &cont, const U &value)
从容器中删除所有等于指定值的元素
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素
void swap()=delete
删除无参数的swap重载
NEFORCE_INLINE17 constexpr bool is_nothrow_swappable_v
is_nothrow_swappable的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_allocator_v
is_allocator的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_nothrow_default_constructible_v
is_nothrow_default_constructible的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_nothrow_destructible_v
is_nothrow_destructible的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_nothrow_move_constructible_v
is_nothrow_move_constructible的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_nothrow_copy_constructible_v
is_nothrow_copy_constructible的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_same_v
is_same的便捷变量模板
typename conditional< Test, T1, T2 >::type conditional_t
conditional的便捷别名
void increment() noexcept
递增操作(移动到中序遍历的后继节点)
rb_tree_node_base::base_ptr base_ptr
基类指针类型
void decrement() noexcept
递减操作(移动到中序遍历的前驱节点)
bidirectional_iterator_tag iterator_category
双向迭代器
conditional_t< IsConst, typename container_type::const_pointer, typename container_type::pointer > pointer
指针类型
NEFORCE_CONSTEXPR20 void increment() noexcept
递增操作
NEFORCE_CONSTEXPR20 void decrement() noexcept
递减操作
typename container_type::size_type size_type
大小类型
typename container_type::difference_type difference_type
差值类型
RbTree container_type
容器类型
NEFORCE_NODISCARD pointer base() const noexcept
获取底层指针
conditional_t< IsConst, typename container_type::const_reference, typename container_type::reference > reference
引用类型
NEFORCE_NODISCARD bool equal(const rb_tree_iterator &rhs) const noexcept
相等比较
rb_tree_base_iterator::iterator_category iterator_category
迭代器类别(双向)
NEFORCE_NODISCARD reference dereference() const noexcept
解引用操作
NEFORCE_NODISCARD const container_type * container() const noexcept
获取关联容器
typename container_type::value_type value_type
值类型
static base_ptr maximum(base_ptr root) noexcept
获取子树中的最大节点
static base_ptr minimum(base_ptr root) noexcept
获取子树中的最小节点
color_type color_
节点颜色,默认为红色
rb_tree_node_base * base_ptr
基类指针类型
rb_tree_node() noexcept(is_nothrow_default_constructible_v< T >)
默认构造函数