Browse Source

avl_tree: bug fix

undefined
Guillaume Bittoun Sam Hocevar <sam@hocevar.net> 9 years ago
parent
commit
e7c7a54273
1 changed files with 5 additions and 8 deletions
  1. +5
    -8
      src/lol/base/avl_tree.h

+ 5
- 8
src/lol/base/avl_tree.h View File

@@ -386,23 +386,22 @@ protected:
if (replacement) if (replacement)
{ {
*replacement->m_parent_slot = replacement->m_child[1 - i]; *replacement->m_parent_slot = replacement->m_child[1 - i];
if (*replacement->m_parent_slot)
(*replacement->m_parent_slot)->rebalance_if_needed();


replacement->m_parent_slot = m_parent_slot; replacement->m_parent_slot = m_parent_slot;
*replacement->m_parent_slot = replacement; *replacement->m_parent_slot = replacement;


replacement->m_child[0] = m_child[0]; replacement->m_child[0] = m_child[0];
if (replacement->m_child[0])
replacement->m_child[0]->m_parent_slot = &replacement->m_child[0];

replacement->m_child[1] = m_child[1]; replacement->m_child[1] = m_child[1];
if (replacement->m_child[1])
replacement->m_child[1]->m_parent_slot = &replacement->m_child[1];
} }
else else
*m_parent_slot = nullptr; *m_parent_slot = nullptr;


replace_chain(replacement); replace_chain(replacement);

m_parent_slot = nullptr;
m_child[0] = nullptr;
m_child[1] = nullptr;
} }


void replace_chain(tree_node * replacement) void replace_chain(tree_node * replacement)
@@ -423,8 +422,6 @@ protected:
if (m_chain[i]) if (m_chain[i])
m_chain[i]->m_chain[i ? 0 : 1] = m_chain[i ? 0 : 1]; m_chain[i]->m_chain[i ? 0 : 1] = m_chain[i ? 0 : 1];
} }

m_chain[i] = nullptr;
} }
} }




Loading…
Cancel
Save