2 #include "btree_data.h"
4 BTreeData::BTreeData (uchar *node)
6 /* TODO : Aca deberia detectar el tipo de clave (necesito
9 clave = new ClaveFija (node);
10 node += clave->Size ();
12 memcpy (&hijo, node, sizeof (uint));
15 BTreeData::BTreeData (Clave *k, uint child)
21 BTreeData::~BTreeData ()
25 uint BTreeData::Size () const
27 uint s = sizeof (uint);
28 if (clave) s += clave->Size ();
29 else std::cout << "No tengo clave\n";
33 uchar* BTreeData::ToArray () const
35 uchar *out = new uchar[Size()];
37 memcpy (out, clave->ToArray (), clave->Size ());
38 memcpy (out+clave->Size (), &hijo, sizeof (uint));
40 memcpy (out, &hijo, sizeof (uint));
44 bool BTreeData::operator < (const BTreeData &data) const
46 if (!data.clave) return false;
48 return (*clave) < (*(data.clave));
52 BTreeLeafData::~BTreeLeafData ()
56 uint BTreeLeafData::Size () const
59 std::cout << "BTreeLeafData::Size : No tengo clave!" << std::endl;
62 return clave->Size ();
65 uchar* BTreeLeafData::ToArray () const
67 return clave->ToArray ();
70 BTreeChildData::BTreeChildData (uchar *node)
72 memcpy (&hijo, node, sizeof (uint));
75 BTreeChildData::~BTreeChildData ()
79 uint BTreeChildData::Size () const
84 uchar* BTreeChildData::ToArray () const
86 uchar *out = new uchar[Size()];
87 memcpy (out, &hijo, sizeof (uint));