Quellcode durchsuchen

avl_tree: removing this useless cascade stuff.

undefined
Guillaume Bittoun Sam Hocevar <sam@hocevar.net> vor 10 Jahren
Ursprung
Commit
f39d5f521c
1 geänderte Dateien mit 12 neuen und 26 gelöschten Zeilen
  1. +12
    -26
      src/lol/algorithm/avl_tree.h

+ 12
- 26
src/lol/algorithm/avl_tree.h Datei anzeigen

@@ -35,12 +35,7 @@ public:

avl_tree & operator=(avl_tree const & other)
{
if (this->m_root)
{
this->m_root->cascade_delete();
delete this->m_root;
this->m_root = nullptr;
}
this->clear();

this->m_count = other->m_count;

@@ -50,11 +45,7 @@ public:

~avl_tree()
{
if (this->m_root)
{
this->m_root->cascade_delete();
delete this->m_root;
}
this->clear();
}

bool insert(K const & key, V const & value)
@@ -101,11 +92,18 @@ public:
{
if (this->m_root)
{
this->m_root->cascade_delete();
delete this->m_root;
this->m_root = nullptr;
tree_node * node = nullptr;
this->m_root->get_min(node);

while (node)
{
tree_node * next = node->get_next();
delete node;
node = next;
}
}

this->m_root = nullptr;
this->m_count = 0;
}

@@ -313,18 +311,6 @@ protected:
max_node = max_node->m_child[1];
}

void cascade_delete()
{
for (int i = 0 ; i < 2 ; ++i)
{
if (this->m_child[i])
{
this->m_child[i]->cascade_delete();
delete this->m_child[i];
}
}
}

int get_balance() const
{
return this->m_stairs[1] - this->m_stairs[0];


Laden…
Abbrechen
Speichern