No es el mejor lugar para poner algo olvidado. Pero es el menos
brain-damage :)
virtual bool operator < (const Clave &k) const = 0;
virtual bool operator == (const Clave &k) const = 0;
virtual operator std::string () const = 0;
virtual bool operator < (const Clave &k) const = 0;
virtual bool operator == (const Clave &k) const = 0;
virtual operator std::string () const = 0;
+ protected:
+ uint block_data;
#include <string>
#include "clave_fija.h"
#include <string>
#include "clave_fija.h"
-ClaveFija::ClaveFija (int n)
+ClaveFija::ClaveFija (int n, uint bd)
}
ClaveFija::ClaveFija (uchar *n)
{
memcpy (&data, n, sizeof(int));
}
ClaveFija::ClaveFija (uchar *n)
{
memcpy (&data, n, sizeof(int));
+ memcpy (&block_data, n+sizeof(int), sizeof(int));
}
uint ClaveFija::Size () const
{
}
uint ClaveFija::Size () const
{
+ return sizeof (int)+sizeof(uint);
}
uchar *ClaveFija::ToArray () const
{
uchar *out;
}
uchar *ClaveFija::ToArray () const
{
uchar *out;
- out = new uchar[sizeof(int)];
+ out = new uchar[Size ()];
memcpy (out, &data, sizeof(int));
memcpy (out, &data, sizeof(int));
+ memcpy (out+sizeof (int), &block_data, sizeof(int));
class ClaveFija : public Clave {
public :
ClaveFija (uchar *n);
class ClaveFija : public Clave {
public :
ClaveFija (uchar *n);
+ ClaveFija (int n, uint data);
virtual ~ClaveFija () {}
uint Size () const;
virtual ~ClaveFija () {}
uint Size () const;
#include "clave_variable.h"
#include <iostream>
#include "clave_variable.h"
#include <iostream>
-ClaveVariable::ClaveVariable (const std::string &s)
+ClaveVariable::ClaveVariable (const std::string &s, uint bd)
}
ClaveVariable::ClaveVariable (uchar *n)
}
ClaveVariable::ClaveVariable (uchar *n)
str[len] = '\0';
data = std::string ((const char *)(str));
delete [] str;
str[len] = '\0';
data = std::string ((const char *)(str));
delete [] str;
+ n += data.size () * sizeof (uchar);
+ memcpy (&block_data, n, sizeof (uint));
+
raw_data = data;
}
uint ClaveVariable::Size () const
{
raw_data = data;
}
uint ClaveVariable::Size () const
{
- return data.size ()*sizeof (uchar)+sizeof (uint);
+ return data.size ()*sizeof (uchar)+sizeof (uint)*2;
}
uchar *ClaveVariable::ToArray () const
}
uchar *ClaveVariable::ToArray () const
uchar *out;
uint len = data.size ();
out = new uchar[Size ()];
uchar *out;
uint len = data.size ();
out = new uchar[Size ()];
memcpy (out, &len, sizeof (uint));
memcpy (out, &len, sizeof (uint));
- memcpy (out+sizeof(uint), data.c_str (), data.size ()*sizeof (uchar));
+ x += sizeof (uint);
+ memcpy (out+x, data.c_str (), data.size ()*sizeof (uchar));
+ x += data.size () * sizeof (uchar);
+ memcpy (out+x, &block_data, sizeof (uint));
+
class ClaveVariable : public Clave {
public :
ClaveVariable (uchar *n);
class ClaveVariable : public Clave {
public :
ClaveVariable (uchar *n);
- ClaveVariable (const std::string &s);
+ ClaveVariable (const std::string &s, uint bd);
virtual ~ClaveVariable () {}
uint Size () const;
virtual ~ClaveVariable () {}
uint Size () const;
it = lst.begin ();
while (it != lst.end ()) {
it = lst.begin ();
while (it != lst.end ()) {
double l = Random::Double (0.0f, 1.0f);
std::cout << l << " >= " << paltas << std::endl;
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. */
} else {
/* Tengo que borrar una clave entre 0 e "i" de la lista
* porque son las que ya agregue. */
- ClaveFija c(km.GetRandom ());
+ ClaveFija c(km.GetRandom (), 0);
int bien = 0;
int mal = 0;
while (it != l.end ()) {
int bien = 0;
int mal = 0;
while (it != l.end ()) {
BTreeFindResult *r;
r = tree.FindKey (c);
BTreeFindResult *r;
r = tree.FindKey (c);
it = lst.begin ();
while (it != lst.end ()) {
it = lst.begin ();
while (it != lst.end ()) {
+ ClaveVariable c(*it, 0);
double l = Random::Double (0.0f, 1.0f);
std::cout << l << " >= " << paltas << std::endl;
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. */
} else {
/* Tengo que borrar una clave entre 0 e "i" de la lista
* porque son las que ya agregue. */
- ClaveVariable c(km.GetRandom ());
+ ClaveVariable c(km.GetRandom (), 0);
int bien = 0;
int mal = 0;
while (it != l.end ()) {
int bien = 0;
int mal = 0;
while (it != l.end ()) {
+ ClaveVariable c(*it, 0);
BTreeFindResult *r;
r = tree.FindKey (c);
BTreeFindResult *r;
r = tree.FindKey (c);