X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/f4c34c38f2c62087bbf7e0d6e618660f0e48023e..57dbb7df8973a3e0c0c570c1eae9d84802e02bd9:/src/btree.h?ds=sidebyside diff --git a/src/btree.h b/src/btree.h index cf9cc30..ef9f242 100644 --- a/src/btree.h +++ b/src/btree.h @@ -73,6 +73,7 @@ #include "clave_fija.h" #include "clave_variable.h" #include "btree_data.h" +#include "exception.h" /* alias para codear menos :) */ @@ -121,7 +122,7 @@ struct BTreeFindResult { */ class BTree { public: - BTree (const std::string &filename, unsigned int block_size, int k_t = KEY_FIXED, bool create_new_file = false); + BTree (const std::string &filename, unsigned int block_size, int t_t = TYPE_UNIQUE, int k_t = KEY_FIXED, bool create_new_file = false); ~BTree (); /** Tipos de clave a usar */ @@ -130,6 +131,11 @@ class BTree { KEY_VARIABLE /**< Utilización de clave de longitud variable */ }; + enum { + TYPE_UNIQUE, + TYPE_SELECTIVE + }; + /** Agrega una nueva clave al árbol. */ void AddKey (const Clave &k); /** Elimina una clave del árbol. */ @@ -140,7 +146,7 @@ class BTree { */ BTreeFindResult *FindKey (const Clave &k); - protected: + //protected: /* Funciones de Alta */ 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); @@ -149,9 +155,11 @@ class BTree { /* Funciones de Baja */ void DelKeyR (BTreeData *k, uint node, uint padre); void DelKeyFromLeaf (Clave *k, uint node_num, uint padre); - void DelKeyFromOther (const Clave &k, BTreeFindResult *r); - void FindB (uint node_num, uint padre, uint &left, uint &right); + void DelKeyFromNode (Clave *k, uint node_num, uint padre, uint left, uint right); + void FindBrothers (uint node_num, uint padre, uint &left, uint &right); + Clave *ReplaceKeyInFather (uint node_num, uint padre, Clave *k); Clave *GetKey (uint node_num, char maxmin); + void JoinNodes (uint node1, uint node2, uint padre, int); /* Funciones de Búsqueda */ BTreeFindResult *FindKeyR (const Clave *k, uint node); @@ -173,9 +181,14 @@ class BTree { void WriteKeys (uchar *node, BTreeNodeHeader &node_header, std::list &keys); void DeleteKeys (std::list &keys); + /* Abreviacion de Claves */ + void AbrevKey (std::list &lst); + void DeAbrevKey (std::list &lst); + std::string filename; BTreeFileHeader header; int key_type; + int tree_type; /** Apunta al archivo de datos, asi se abre solo 1 vez *