]> git.llucax.com Git - z.facultad/75.52/treemulator.git/blobdiff - src/btree.cpp
Implemento recuperacion de blockdata.
[z.facultad/75.52/treemulator.git] / src / btree.cpp
index fc62f5ba108079ad1de6177848f5ad49e1ba88f6..575ca597b6eff9d07f4e21028df4015d188108c2 100644 (file)
@@ -582,6 +582,7 @@ void BTree::DelKeyFromLeaf (Clave *k, uint node_num, uint padre)
                if ((*data) == (*(*it))) {
                        BTreeData *aborrar = (*it);
                        node_keys.erase (it);
+                       deleted_block_data.push_back (aborrar->GetKey ()->GetBlockData ());
                        delete aborrar;
                        break;
                }
@@ -1301,7 +1302,15 @@ int BTree::type () const
 
 uint BTree::GetNextBlockData ()
 {
-       /* TODO : Implementar recuperacion */
-       return header.block_data_counter++;
+       uint n;
+       if (deleted_block_data.size ()) {
+               std::list<uint>::iterator it = deleted_block_data.begin ();
+               n = *it;
+               deleted_block_data.erase (it);
+       } else {
+               n = header.block_data_counter++;
+       }
+
+       return n;
 }