Browse Source

avl_tree: tiny fixes + iterator features.

undefined
Guillaume Bittoun Sam Hocevar <sam@hocevar.net> 10 years ago
parent
commit
a9e67e2cc1
1 changed files with 27 additions and 3 deletions
  1. +27
    -3
      src/lol/algorithm/avl_tree.h

+ 27
- 3
src/lol/algorithm/avl_tree.h View File

@@ -76,8 +76,8 @@ public:
if (this->m_root) if (this->m_root)
{ {
this->m_root->get_min(min_node); this->m_root->get_min(min_node);
key_ptr = &min_node->m_key;
value_ptr = &min_node->m_value;
key_ptr = &min_node->get_key();
value_ptr = &min_node->get_value();


return true; return true;
} }
@@ -92,7 +92,8 @@ public:
if (this->m_root) if (this->m_root)
{ {
this->m_root->get_max(max_node); this->m_root->get_max(max_node);
value_ptr = &max_node->value;
key_ptr = &max_node->get_key();
value_ptr = &max_node->get_value();


return true; return true;
} }
@@ -100,6 +101,29 @@ public:
return false; return false;
} }


class Iterator;
class ConstIterator;

Iterator get_iterator()
{
tree_node * node = nullptr;

if (this->m_root)
node = this->m_root->get_min();

return Iterator(node);
}

ConstIterator get_iterator() const
{
tree_node * node = nullptr;

if (this->m_root)
node = this->m_root->get_min();

return ConstIterator(node);
}

protected: protected:


class tree_node class tree_node


Loading…
Cancel
Save