From: Ricardo Markiewicz Date: Wed, 23 Nov 2005 02:47:02 +0000 (+0000) Subject: Incremento automatico de block_data. X-Git-Tag: 1_0~9 X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/commitdiff_plain/477697002803b11be48f7a9317c6c0f82e646cb9?ds=sidebyside;hp=2f18bb22e1573898bb70f0a46897fbd032ef2734 Incremento automatico de block_data. --- diff --git a/src/btree.cpp b/src/btree.cpp index 77967bf..fc62f5b 100644 --- a/src/btree.cpp +++ b/src/btree.cpp @@ -19,6 +19,7 @@ BTree::BTree (const std::string &name, unsigned int block_size, int tt, int kt, header.block_size = block_size; header.tree_type = tt; header.key_type = kt; + header.block_data_counter = 0; WriteFileHeader (); /* Creo el primer bloque vacio */ @@ -100,8 +101,7 @@ void BTree::AddKey (const Clave &k) Clave *kout, *in; in = k.Clone (); - /* TODO : Hacer un contador con recuperacion */ - in->SetBlockData (0); + in->SetBlockData ( GetNextBlockData () ); try { kout = AddKeyR (in->Clone (), 0, left, right); @@ -1298,3 +1298,10 @@ int BTree::type () const { return header.key_type; } + +uint BTree::GetNextBlockData () +{ + /* TODO : Implementar recuperacion */ + return header.block_data_counter++; +} + diff --git a/src/btree.h b/src/btree.h index 6feb5a8..1c08df4 100644 --- a/src/btree.h +++ b/src/btree.h @@ -210,6 +210,7 @@ struct BTreeFileHeader { uint block_size; int tree_type; int key_type; + uint block_data_counter; }; /** Encabezado de un bloque */ @@ -319,6 +320,8 @@ class BTree { std::string filename; BTreeFileHeader header; + uint GetNextBlockData (); + /** Apunta al archivo de datos, asi se abre solo 1 vez * * \todo Ver si vale la pena