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

◆ insertFixup()

template<typename T, typename Compare = less<T>, typename Allocator = allocator_slab<char>>
void fl::RedBlackTree< T, Compare, Allocator >::insertFixup ( RBNode * z)
inlineprivate

Definition at line 103 of file rbtree.h.

103 {
104 while (z->parent != nullptr && z->parent->parent != nullptr && z->parent->color == Color::kRed) {
105 if (z->parent == z->parent->parent->left) {
106 RBNode* y = z->parent->parent->right;
107 if (y != nullptr && y->color == Color::kRed) {
108 z->parent->color = Color::kBlack;
109 y->color = Color::kBlack;
110 z->parent->parent->color = Color::kRed;
111 z = z->parent->parent;
112 } else {
113 if (z == z->parent->right) {
114 z = z->parent;
115 rotateLeft(z);
116 }
117 z->parent->color = Color::kBlack;
118 z->parent->parent->color = Color::kRed;
119 rotateRight(z->parent->parent);
120 }
121 } else {
122 RBNode* y = z->parent->parent->left;
123 if (y != nullptr && y->color == Color::kRed) {
124 z->parent->color = Color::kBlack;
125 y->color = Color::kBlack;
126 z->parent->parent->color = Color::kRed;
127 z = z->parent->parent;
128 } else {
129 if (z == z->parent->left) {
130 z = z->parent;
131 rotateRight(z);
132 }
133 z->parent->color = Color::kBlack;
134 z->parent->parent->color = Color::kRed;
135 rotateLeft(z->parent->parent);
136 }
137 }
138 }
139 mRoot->color = Color::kBlack;
140 }
void rotateRight(RBNode *x)
Definition rbtree.h:85
void rotateLeft(RBNode *x)
Definition rbtree.h:67
RBNode * mRoot
Definition rbtree.h:61

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

+ Here is the caller graph for this function: