MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / insert

Method insert

switch/source/gfx/CIntrusiveTree.cpp:108–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108void CIntrusiveTreeBase::insert(N* node, N* parent)
109{
110 node->left() = node->right() = nullptr;
111 node->setParent(parent);
112 node->setRed();
113
114 while ((parent = node->getParent()) && parent->isRed())
115 {
116 N *grandparent = parent->getParent();
117 N::Leaf leaf = parent == grandparent->left() ? N::Right : N::Left;
118 N *uncle = grandparent->child(leaf);
119
120 if (uncle && uncle->isRed())
121 {
122 uncle->setBlack();
123 parent->setBlack();
124 grandparent->setRed();
125
126 node = grandparent;
127 }
128 else
129 {
130 if (parent->child(leaf) == node)
131 {
132 rotate(parent, leaf);
133
134 N* tmp = parent;
135 parent = node;
136 node = tmp;
137 }
138
139 parent->setBlack();
140 grandparent->setRed();
141 rotate(grandparent, !leaf);
142 }
143 }
144
145 m_root->setBlack();
146}
147
148void CIntrusiveTreeBase::remove(N* node)
149{

Callers 12

getCompleteTitleListMethod · 0.45
titleListForSaveTypeMethod · 0.45
requestMethod · 0.45
invalidateMethod · 0.45
refreshDirectoriesMethod · 0.45
usernameMethod · 0.45
shortNameMethod · 0.45
iconMethod · 0.45
loadIconMethod · 0.45
loadPlaceholderIconMethod · 0.45
allocateMethod · 0.45
_destroyMethod · 0.45

Calls 5

setParentMethod · 0.80
setRedMethod · 0.80
getParentMethod · 0.80
isRedMethod · 0.80
setBlackMethod · 0.80

Tested by

no test coverage detected