MCPcopy Create free account
hub / github.com/acm-clan/algorithm-stone / insert

Method insert

templates/rb.cpp:172–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170 }
171
172 void insert(RBTreeNode* n, RBTreeNode* z)
173 {
174 auto y = nil;
175 auto x = root;
176 // 找到父节点
177 while (x != nil) {
178 y = x;
179 if (z->k < x->k) {
180 x = x->left;
181 } else {
182 x = x->right;
183 }
184 }
185
186 z->p = y;
187 y->addChild(this, z);
188 insert_fixup(z);
189 }
190
191 void dumpInternal(RBTreeNode* n, int d)
192 {

Callers

nothing calls this directly

Calls 1

addChildMethod · 0.45

Tested by

no test coverage detected