You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The call to RecalculateMaxEnd occurs in a loop and goes up the tree, but RecalculateMaxEnd also does this. It seems that the extra while loop is redundant.
while (node.Parent != Sentinel) {
node = node.Parent;
node.RecalculateMaxEnd();
}
More context below.
private void RemoveNode(IntervalNode<T> node)
{
if (node == Sentinel) {
return;
}
IntervalNode<T> temp = node;
if (node.Right != Sentinel && node.Left != Sentinel) {
// Trick when deleting node with both children, switch it with closest in order node
// swap values and delete the bottom node converting it to other cases
temp = node.GetSuccessor();
node.Interval = temp.Interval;
node.RecalculateMaxEnd();
while (node.Parent != Sentinel) {
node = node.Parent;
node.RecalculateMaxEnd();
}
}
node = temp;
temp = node.Left != Sentinel ? node.Left : node.Right;
// we will replace node with temp and delete node
temp.Parent = node.Parent;
if (node.IsRoot) {
Root = temp; // Set new root
} else {
// Reattach node to parent
if (node.ParentDirection == NodeDirection.RIGHT) {
node.Parent.Left = temp;
} else {
node.Parent.Right = temp;
}
IntervalNode<T> maxAux = node.Parent;
maxAux.RecalculateMaxEnd();
while (maxAux.Parent != Sentinel) {
maxAux = maxAux.Parent;
maxAux.RecalculateMaxEnd();
}
}
if (node.Color == NodeColor.BLACK) {
RenewConstraintsAfterDelete(temp);
}
}
The text was updated successfully, but these errors were encountered:
The call to RecalculateMaxEnd occurs in a loop and goes up the tree, but RecalculateMaxEnd also does this. It seems that the extra while loop is redundant.
More context below.
The text was updated successfully, but these errors were encountered: