From: Ricardo Markiewicz Date: Wed, 23 Nov 2005 01:53:24 +0000 (+0000) Subject: Paso el block_data a BTree en lugar de Clave. X-Git-Tag: 1_0~11 X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/commitdiff_plain/aa158a0284c1bc32a979d50275aa1b24438d46ef Paso el block_data a BTree en lugar de Clave. --- diff --git a/src/btree.cpp b/src/btree.cpp index e78a91e..77967bf 100644 --- a/src/btree.cpp +++ b/src/btree.cpp @@ -97,14 +97,20 @@ void BTree::WriteBlock (uchar *block, uint num) void BTree::AddKey (const Clave &k) { uint left, right; - Clave *kout; + Clave *kout, *in; + + in = k.Clone (); + /* TODO : Hacer un contador con recuperacion */ + in->SetBlockData (0); try { - kout = AddKeyR (k.Clone (), 0, left, right); + kout = AddKeyR (in->Clone (), 0, left, right); } catch (Exception *e) { throw e; } + delete in; + if (kout) { unsigned short level; /* Debo dejar la raiz en el nodo 0, por lo que paso el nodo diff --git a/src/clave.h b/src/clave.h index 27e9487..1d746b8 100644 --- a/src/clave.h +++ b/src/clave.h @@ -10,6 +10,8 @@ class Clave { public: virtual ~Clave () {} + void SetBlockData (int i) { block_data = i; } + /** Retorna el tamaƱo en bytes que ocupa la clave */ virtual uint Size () const = 0; /** Retorna un array de bytes de Size() de longitud. diff --git a/src/clave_fija.cpp b/src/clave_fija.cpp index d947e2a..ea8c09e 100644 --- a/src/clave_fija.cpp +++ b/src/clave_fija.cpp @@ -2,10 +2,9 @@ #include #include "clave_fija.h" -ClaveFija::ClaveFija (int n, uint bd) +ClaveFija::ClaveFija (int n) { data = n; - block_data = bd; } ClaveFija::ClaveFija (uchar *n) diff --git a/src/clave_fija.h b/src/clave_fija.h index d04baf9..e70cd52 100644 --- a/src/clave_fija.h +++ b/src/clave_fija.h @@ -9,7 +9,7 @@ class ClaveFija : public Clave { public : ClaveFija (uchar *n); - ClaveFija (int n, uint data); + ClaveFija (int n); virtual ~ClaveFija () {} uint Size () const; diff --git a/src/clave_variable.cpp b/src/clave_variable.cpp index 4479a15..e4452b0 100644 --- a/src/clave_variable.cpp +++ b/src/clave_variable.cpp @@ -3,10 +3,9 @@ #include "clave_variable.h" #include -ClaveVariable::ClaveVariable (const std::string &s, uint bd) +ClaveVariable::ClaveVariable (const std::string &s) { data = s; - block_data = bd; } ClaveVariable::ClaveVariable (uchar *n) diff --git a/src/clave_variable.h b/src/clave_variable.h index b92448b..224f4e0 100644 --- a/src/clave_variable.h +++ b/src/clave_variable.h @@ -13,7 +13,7 @@ class ClaveVariable : public Clave { public : ClaveVariable (uchar *n); - ClaveVariable (const std::string &s, uint bd); + ClaveVariable (const std::string &s); virtual ~ClaveVariable () {} uint Size () const; diff --git a/src/main.cpp b/src/main.cpp index e4f0326..a16a24e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,7 +29,7 @@ int main (int argc, char *argv[]) it = lst.begin (); while (it != lst.end ()) { - ClaveFija c(*it, 0); + ClaveFija c(*it); double l = Random::Double (0.0f, 1.0f); std::cout << l << " >= " << paltas << std::endl; @@ -45,7 +45,7 @@ int main (int argc, char *argv[]) } else { /* Tengo que borrar una clave entre 0 e "i" de la lista * porque son las que ya agregue. */ - ClaveFija c(km.GetRandom (), 0); + ClaveFija c(km.GetRandom ()); try { tree.DelKey (c); @@ -64,7 +64,7 @@ int main (int argc, char *argv[]) int bien = 0; int mal = 0; while (it != l.end ()) { - ClaveFija c(*it, 0); + ClaveFija c(*it); BTreeFindResult *r; r = tree.FindKey (c); diff --git a/src/main_var.cpp b/src/main_var.cpp index 8202096..d7082c9 100644 --- a/src/main_var.cpp +++ b/src/main_var.cpp @@ -29,7 +29,7 @@ int main (int argc, char *argv[]) it = lst.begin (); while (it != lst.end ()) { - ClaveVariable c(*it, 0); + ClaveVariable c(*it); double l = Random::Double (0.0f, 1.0f); std::cout << l << " >= " << paltas << std::endl; @@ -47,7 +47,7 @@ int main (int argc, char *argv[]) } else { /* Tengo que borrar una clave entre 0 e "i" de la lista * porque son las que ya agregue. */ - ClaveVariable c(km.GetRandom (), 0); + ClaveVariable c(km.GetRandom ()); try { tree.DelKey (c); @@ -66,7 +66,7 @@ int main (int argc, char *argv[]) int bien = 0; int mal = 0; while (it != l.end ()) { - ClaveVariable c(*it, 0); + ClaveVariable c(*it); BTreeFindResult *r; r = tree.FindKey (c);