X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/6a4238b2894a1cf20a5b8ccb0575f018ae25a5b3..2f18bb22e1573898bb70f0a46897fbd032ef2734:/src/btree_data.cpp diff --git a/src/btree_data.cpp b/src/btree_data.cpp index bc0ce93..1adeb83 100644 --- a/src/btree_data.cpp +++ b/src/btree_data.cpp @@ -24,8 +24,10 @@ BTreeData::BTreeData (Clave *k, uint child) BTreeData::~BTreeData () { - if (clave) + if (clave) { delete clave; + clave = NULL; + } } uint BTreeData::Size () const @@ -63,8 +65,25 @@ bool BTreeData::operator == (const BTreeData &data) const return (*clave) == (*(data.clave)); } +bool BTreeData::Abrev (BTreeData *anterior) +{ + if (anterior == NULL) return false; + + ClaveVariable *c = (ClaveVariable *)clave; + return c->Abrev (dynamic_cast(anterior->GetKey ())); +} + +bool BTreeData::DesAbrev (BTreeData *anterior) +{ + if (anterior == NULL) return false; + + ClaveVariable *c = (ClaveVariable *)clave; + return c->DesAbrev (dynamic_cast(anterior->GetKey ())); +} + BTreeLeafData::BTreeLeafData (uchar *node, int key_type) { + hijo = 0; if (key_type == BTree::KEY_FIXED) clave = new ClaveFija (node); else @@ -73,6 +92,10 @@ BTreeLeafData::BTreeLeafData (uchar *node, int key_type) BTreeLeafData::~BTreeLeafData () { + if (clave) { + delete clave; + clave = NULL; + } } uint BTreeLeafData::Size () const @@ -92,6 +115,7 @@ uchar* BTreeLeafData::ToArray () const BTreeChildData::BTreeChildData (uchar *node) { memcpy (&hijo, node, sizeof (uint)); + clave = NULL; } BTreeChildData::~BTreeChildData () @@ -110,3 +134,7 @@ uchar* BTreeChildData::ToArray () const return out; } +bool BTreeChildData::operator < (const BTreeData &data) const +{ + return false; +}