X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/6eca7410b5a4c3c5225d852dd1d1ce9b74a7f4cd..2ab8041933e77875de62bc73e76febc528af258e:/src/btree_data.cpp?ds=sidebyside diff --git a/src/btree_data.cpp b/src/btree_data.cpp index 1203d6c..a5d9b68 100644 --- a/src/btree_data.cpp +++ b/src/btree_data.cpp @@ -1,12 +1,16 @@ #include "btree_data.h" +#include "btree.h" -BTreeData::BTreeData (uchar *node) +BTreeData::BTreeData (uchar *node, int tree_type) { /* TODO : Aca deberia detectar el tipo de clave (necesito * info desde el arbol */ - clave = new ClaveFija (node); + if (tree_type == BTree::KEY_FIXED) + clave = new ClaveFija (node); + else + clave = new ClaveVariable (node); node += clave->Size (); memcpy (&hijo, node, sizeof (uint)); @@ -48,6 +52,20 @@ bool BTreeData::operator < (const BTreeData &data) const return (*clave) < (*(data.clave)); } +bool BTreeData::operator == (const BTreeData &data) const +{ + if (!data.clave) return false; + + return (*clave) == (*(data.clave)); +} + +BTreeLeafData::BTreeLeafData (uchar *node, int key_type) +{ + if (key_type == BTree::KEY_FIXED) + clave = new ClaveFija (node); + else + clave = new ClaveVariable (node); +} BTreeLeafData::~BTreeLeafData () {