FastLED 3.9.15
Loading...
Searching...
No Matches

◆ deleteFixup()

template<typename T, typename Compare = less<T>, typename Allocator = allocator_slab<char>>
void fl::RedBlackTree< T, Compare, Allocator >::deleteFixup ( Node * x,
Node * xParent )
inlineprivate

Definition at line 163 of file rbtree.h.

163 {
164 while ((x != root_) && (x == nullptr || x->color == BLACK)) {
165 if (x == (xParent ? xParent->left : nullptr)) {
166 Node* w = xParent ? xParent->right : nullptr;
167 if (w && w->color == RED) {
168 w->color = BLACK;
169 if (xParent) { xParent->color = RED; rotateLeft(xParent); }
170 w = xParent ? xParent->right : nullptr;
171 }
172 bool wLeftBlack = (!w || !w->left || w->left->color == BLACK);
173 bool wRightBlack = (!w || !w->right || w->right->color == BLACK);
174 if (wLeftBlack && wRightBlack) {
175 if (w) w->color = RED;
176 x = xParent;
177 xParent = xParent ? xParent->parent : nullptr;
178 } else {
179 if (!w || (w->right == nullptr || w->right->color == BLACK)) {
180 if (w && w->left) w->left->color = BLACK;
181 if (w) { w->color = RED; rotateRight(w); }
182 w = xParent ? xParent->right : nullptr;
183 }
184 if (w) w->color = xParent ? xParent->color : BLACK;
185 if (xParent) xParent->color = BLACK;
186 if (w && w->right) w->right->color = BLACK;
188 x = root_;
189 }
190 } else {
191 Node* w = xParent ? xParent->left : nullptr;
192 if (w && w->color == RED) {
193 w->color = BLACK;
194 if (xParent) { xParent->color = RED; rotateRight(xParent); }
195 w = xParent ? xParent->left : nullptr;
196 }
197 bool wRightBlack = (!w || !w->right || w->right->color == BLACK);
198 bool wLeftBlack = (!w || !w->left || w->left->color == BLACK);
199 if (wRightBlack && wLeftBlack) {
200 if (w) w->color = RED;
201 x = xParent;
202 xParent = xParent ? xParent->parent : nullptr;
203 } else {
204 if (!w || (w->left == nullptr || w->left->color == BLACK)) {
205 if (w && w->right) w->right->color = BLACK;
206 if (w) { w->color = RED; rotateLeft(w); }
207 w = xParent ? xParent->left : nullptr;
208 }
209 if (w) w->color = xParent ? xParent->color : BLACK;
210 if (xParent) xParent->color = BLACK;
211 if (w && w->left) w->left->color = BLACK;
213 x = root_;
214 }
215 }
216 }
217 if (x) x->color = BLACK;
218 }
void rotateRight(Node *x)
Definition rbtree.h:78
Node * root_
Definition rbtree.h:54
void rotateLeft(Node *x)
Definition rbtree.h:60

Referenced by fl::RedBlackTree< value_type, PairCompare, Allocator >::erase().

+ Here is the caller graph for this function: