memcpy (&hijo, node, sizeof (uint));
}
+BTreeData::BTreeData (Clave *k, uint child)
+{
+ clave = k;
+ hijo = child;
+}
+
BTreeData::~BTreeData ()
{
}
-uint BTreeData::Size ()
+uint BTreeData::Size () const
{
uint s = sizeof (uint);
if (clave) s += clave->Size ();
-
+ else std::cout << "No tengo clave\n";
return s;
}
-uchar* BTreeData::ToArray ()
+uchar* BTreeData::ToArray () const
{
uchar *out = new uchar[Size()];
- memcpy (out, clave->ToArray (), clave->Size ());
- memcpy (out+clave->Size (), &hijo, sizeof (uint));
+ if (clave) {
+ memcpy (out, clave->ToArray (), clave->Size ());
+ memcpy (out+clave->Size (), &hijo, sizeof (uint));
+ } else
+ memcpy (out, &hijo, sizeof (uint));
return out;
}
bool BTreeData::operator < (const BTreeData &data) const
{
+ if (!data.clave) return false;
+
return (*clave) < (*(data.clave));
}
+bool BTreeData::operator == (const BTreeData &data) const
+{
+ if (!data.clave) return false;
+
+ return (*clave) == (*(data.clave));
+}
BTreeLeafData::~BTreeLeafData ()
{
}
-uint BTreeLeafData::Size ()
+uint BTreeLeafData::Size () const
{
+ if (!clave) {
+ std::cout << "BTreeLeafData::Size : No tengo clave!" << std::endl;
+ return 0;
+ }
return clave->Size ();
}
-uchar* BTreeLeafData::ToArray ()
+uchar* BTreeLeafData::ToArray () const
{
return clave->ToArray ();
}
+BTreeChildData::BTreeChildData (uchar *node)
+{
+ memcpy (&hijo, node, sizeof (uint));
+}
+
+BTreeChildData::~BTreeChildData ()
+{
+}
+
+uint BTreeChildData::Size () const
+{
+ return sizeof (uint);
+}
+
+uchar* BTreeChildData::ToArray () const
+{
+ uchar *out = new uchar[Size()];
+ memcpy (out, &hijo, sizeof (uint));
+ return out;
+}
+