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
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.
#include <string>
#include "clave_fija.h"
-ClaveFija::ClaveFija (int n, uint bd)
+ClaveFija::ClaveFija (int n)
{
data = n;
- block_data = bd;
}
ClaveFija::ClaveFija (uchar *n)
class ClaveFija : public Clave {
public :
ClaveFija (uchar *n);
- ClaveFija (int n, uint data);
+ ClaveFija (int n);
virtual ~ClaveFija () {}
uint Size () const;
#include "clave_variable.h"
#include <iostream>
-ClaveVariable::ClaveVariable (const std::string &s, uint bd)
+ClaveVariable::ClaveVariable (const std::string &s)
{
data = s;
- block_data = bd;
}
ClaveVariable::ClaveVariable (uchar *n)
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;
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;
} 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);
int bien = 0;
int mal = 0;
while (it != l.end ()) {
- ClaveFija c(*it, 0);
+ ClaveFija c(*it);
BTreeFindResult *r;
r = tree.FindKey (c);
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;
} 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);
int bien = 0;
int mal = 0;
while (it != l.end ()) {
- ClaveVariable c(*it, 0);
+ ClaveVariable c(*it);
BTreeFindResult *r;
r = tree.FindKey (c);