mirror of https://github.com/PrimeDecomp/prime.git
parent
391f8389d9
commit
99dac1a072
|
@ -115,7 +115,115 @@ void* rbtree_rebalance_for_erase(void* header_void, void* node_void) {
|
|||
_header* header = static_cast< _header* >(header_void);
|
||||
_node* node = static_cast< _node* >(node_void);
|
||||
|
||||
return nullptr;
|
||||
_node* next;
|
||||
_node* result = node;
|
||||
|
||||
if (node->mLeft == nullptr) {
|
||||
next = node->mRight;
|
||||
} else {
|
||||
_node* tmp = node->mRight;
|
||||
if (tmp == nullptr) {
|
||||
next = tmp;
|
||||
} else {
|
||||
do {
|
||||
result = tmp;
|
||||
tmp = result->mLeft;
|
||||
} while (result->mLeft != nullptr);
|
||||
next = result->mRight;
|
||||
}
|
||||
}
|
||||
|
||||
if (result != node) {
|
||||
node->mLeft->mParent = result;
|
||||
result->mLeft = node->mLeft;
|
||||
|
||||
_node* tmp = result;
|
||||
if (result != node->mRight) {
|
||||
tmp = result->mParent;
|
||||
if (next != nullptr) {
|
||||
next->mParent = result->mParent;
|
||||
}
|
||||
result->mParent->mLeft = next;
|
||||
result->mRight = node->mRight;
|
||||
node->mRight->mParent = result;
|
||||
}
|
||||
|
||||
if (header->mRootNode == node) {
|
||||
header->mRootNode = result;
|
||||
} else {
|
||||
if (node->mParent->mLeft == node) {
|
||||
node->mParent->mLeft = result;
|
||||
} else {
|
||||
node->mParent->mRight = result;
|
||||
}
|
||||
}
|
||||
|
||||
result->mParent = node->mParent;
|
||||
node_color c = result->mColor;
|
||||
result->mColor = node->mColor;
|
||||
node->mColor = c;
|
||||
result = node;
|
||||
|
||||
} else {
|
||||
_node* a1 = result->mParent;
|
||||
if (next != nullptr) {
|
||||
next->mParent = a1;
|
||||
}
|
||||
if (header->mRootNode == node) {
|
||||
header->mRootNode = next;
|
||||
} else {
|
||||
if (node->mParent->mLeft == node) {
|
||||
node->mParent->mLeft = next;
|
||||
} else {
|
||||
node->mParent->mRight = next;
|
||||
}
|
||||
}
|
||||
|
||||
if (header->mLeftmost == node) {
|
||||
if (node->mRight == nullptr) {
|
||||
header->mLeftmost = node->mParent;
|
||||
} else {
|
||||
// prVar1 = next;
|
||||
_node* prVar1 = next;
|
||||
if (next == nullptr) {
|
||||
header->mLeftmost = nullptr;
|
||||
} else {
|
||||
_node* newLeftmost;
|
||||
do {
|
||||
newLeftmost = prVar1;
|
||||
prVar1 = newLeftmost->mLeft;
|
||||
} while (newLeftmost->mLeft != nullptr);
|
||||
header->mLeftmost = newLeftmost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (header->mRightmost == node) {
|
||||
if (node->mLeft == nullptr) {
|
||||
header->mRightmost = node->mParent;
|
||||
} else {
|
||||
// prVar1 = next;
|
||||
_node* prVar1 = next;
|
||||
if (next == nullptr) {
|
||||
header->mRightmost = nullptr;
|
||||
} else {
|
||||
_node* newRightmost;
|
||||
do {
|
||||
newRightmost = prVar1;
|
||||
prVar1 = newRightmost->mRight;
|
||||
} while (newRightmost->mRight != nullptr);
|
||||
header->mRightmost = newRightmost;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result->mColor != kNC_Black) {
|
||||
while (true) {
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void* rbtree_traverse_forward(const void* header_void, void* node_void) {
|
||||
|
|
Loading…
Reference in New Issue