abandon changes in balancing algo
This commit is contained in:
@@ -425,25 +425,20 @@ MP_TPL void MP::
|
||||
while (n)
|
||||
{
|
||||
n->height = _compute_height(n);
|
||||
// n->height = _balance_f(n);
|
||||
|
||||
if (_balance_factor(n) > 1) // Left Heavy
|
||||
// if (n->height > 1) // Left Heavy
|
||||
{
|
||||
parent = n->up;
|
||||
if (_balance_factor(n->left) < 0) // Left-Right Case (BF == -1)
|
||||
// if (n->left->height < 0) // Left-Right Case (BF == -1)
|
||||
n->left = _rotate_left(n->left);
|
||||
// Left-Left Case
|
||||
n = _rotate_right(n);
|
||||
old_n = n->right;
|
||||
}
|
||||
// else if (_balance_factor(n) < -1) // Right Heavy
|
||||
else if (n->height < -1) // Right Heavy
|
||||
else if (_balance_factor(n) < -1) // Right Heavy
|
||||
{
|
||||
parent = n->up;
|
||||
if (_balance_factor(n->right) > 0) // Right-Left Case (BF == 1)
|
||||
// if (n->right->height > 0) // Right-Left Case (BF == 1)
|
||||
n->right = _rotate_right(n->right);
|
||||
// Right-Right Case
|
||||
n = _rotate_left(n);
|
||||
@@ -474,18 +469,6 @@ MP_TPL short MP::
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
MP_TPL short MP::
|
||||
_balance_f(node<value_type>* n) {
|
||||
|
||||
if (n->left && n->right)
|
||||
return n->left->height - n->right->height;
|
||||
else if (n->left)
|
||||
return (n->left->height + 1);
|
||||
else if (n->right)
|
||||
return (-1 - (n->right->height));
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
MP_TPL short MP::
|
||||
_balance_factor(node<value_type>* n) {
|
||||
|
||||
@@ -513,8 +496,6 @@ MP_TPL node<typename MP::value_type>* MP::
|
||||
|
||||
n->height = _compute_height(n);
|
||||
ori_right->height = _compute_height(ori_right);
|
||||
// n->height = _balance_f(n);
|
||||
// ori_right->height = _balance_f(ori_right);
|
||||
|
||||
if (n == _root)
|
||||
{
|
||||
@@ -539,8 +520,6 @@ MP_TPL node<typename MP::value_type>* MP::
|
||||
|
||||
n->height = _compute_height(n);
|
||||
ori_left->height = _compute_height(ori_left);
|
||||
// n->height = _balance_f(n);
|
||||
// ori_left->height = _balance_f(ori_left);
|
||||
|
||||
if (n == _root)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user