Changeset 49fbfb5 in mainline
- Timestamp:
- 2018-07-05T21:41:22Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f8bbaa0
- Parents:
- be9eb15
- git-author:
- Dzejrou <dzejrou@…> (2018-04-29 19:22:10)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/internal/rbtree_node.hpp
rbe9eb15 r49fbfb5 30 30 #define LIBCPP_INTERNAL_RBTREE_NODE 31 31 32 #include <utility> 33 32 34 namespace std::aux 33 35 { … … 95 97 } 96 98 99 bool is_right_child() const 100 { 101 if (parent) 102 return parent->right == this; 103 else 104 return false; 105 } 106 97 107 void rotate_left() 98 108 { … … 123 133 } 124 134 135 rbtree_node* successor() 136 { 137 if (right) 138 return right->find_smallest(); 139 else 140 { 141 auto current = this; 142 while (!current->is_left_child()) 143 current = current->parent; 144 145 return current->parent; 146 } 147 } 148 125 149 void add_left_child(rbtree_node* node) 126 150 { … … 141 165 } 142 166 167 void swap(rbtree_node* other) 168 { 169 /** 170 * Parent can be null so we check both ways. 171 */ 172 if (is_left_child()) 173 parent->left = other; 174 else if (is_right_child()) 175 parent->right = other; 176 177 if (other->is_left_child()) 178 other->parent->left = this; 179 else if (other->is_right_child()) 180 other->parent->right = this; 181 182 if (left) 183 left->parent = other; 184 if (right) 185 right->parent = other; 186 if (other->left) 187 other->left->parent = this; 188 if (other->right) 189 other->right->parent = this; 190 191 std::swap(parent, other->parent); 192 std::swap(left, other->left); 193 std::swap(right, other->right); 194 } 195 196 void unlink() 197 { 198 if (is_left_child()) 199 parent->left = nullptr; 200 else if (is_right_child()) 201 parent->right = nullptr; 202 } 203 143 204 ~rbtree_node() 144 205 {
Note:
See TracChangeset
for help on using the changeset viewer.