| | | | | next -> |

Associative Arrays using BST technology

Rehash without Iterators

  class CopyNode
  {
    public:
      CopyNode (Node*& newroot, OAA<K,D>* oaa) : newroot_(newroot), oldtree_(oaa)
      {}
      void operator() (const Node * n) const
      {
        if (n->IsAlive()) // copy a node only if it is alive
        {
          newroot_ = oldtree_->RInsert(newroot_,n->key_, n->data_);
          newroot_->SetBlack();
        }
      }
    private:
      Node *&    newroot_;
      OAA<K,D> * oldtree_;
  };
  void Rehash() // restructure with no tombstones
  {
    Node* newRoot = 0;
    CopyNode cn(newRoot,this);
    Traverse(cn);
    Clear();
    root_ = newRoot;
  }

| next -> | Top of Page | 12. Binary Search Trees - 41 of 41