X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/dba24fb6aa7fe829dc3e96039e7f717b0ef9668e..2ab8041933e77875de62bc73e76febc528af258e:/src/btree.h?ds=sidebyside diff --git a/src/btree.h b/src/btree.h index 7d279f5..a67fa4c 100644 --- a/src/btree.h +++ b/src/btree.h @@ -50,6 +50,8 @@ #include "common.h" #include "clave.h" #include "clave_fija.h" +#include "clave_variable.h" +#include "btree_data.h" /* alias para codear menos :) */ @@ -85,32 +87,48 @@ struct BTreeNodeHeader { */ class BTree { public: - BTree (const std::string &filename, unsigned int block_size, bool create_new_file = false); + BTree (const std::string &filename, unsigned int block_size, int k_t = KEY_FIXED, bool create_new_file = false); ~BTree (); + /** Tipos de clave a usar */ + enum { + KEY_FIXED, + KEY_VARIABLE + }; + void AddKey (const Clave &k); void DelKey (const Clave &k); - private: + protected: + Clave* AddKeyR (const Clave *k, uint node_num, uint &left_child, uint &right_child); + Clave* AddKeyOtherR (const Clave *k, uint node_num, uint &left_child, uint &right_child); + Clave* AddKeyLeafR (const Clave *k, uint node_num, uint &left_child, uint &right_child); + void WriteFileHeader (); void WriteBlock (uchar *block, uint num); uchar *ReadBlock (uint num); + uchar *NewBlock (uint &num); void ReadNodoHeader (uchar *node, BTreeNodeHeader *header); void WriteNodoHeader (uchar *node, BTreeNodeHeader *header); - std::list ReadKeys (uchar *node, BTreeNodeHeader &node_header); - void WriteKeys (uchar *node, BTreeNodeHeader &node_header, std::list &keys); + std::list ReadKeys (uchar *node, BTreeNodeHeader &node_header); + void WriteKeys (uchar *node, BTreeNodeHeader &node_header, std::list &keys); std::string filename; BTreeFileHeader header; + int key_type; /** Apunta al archivo de datos, asi se abre solo 1 vez * * \TODO Ver si vale la pena */ FILE *fp; + + + /* DEBUG */ + void PrintNode (uint num); }; #endif // _B_TREE_H