X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/922dfc7b53d90a143c698842a418ec67a70af640..5ade66d0aa29a2fed034a93326a49b2edcd2e7ec:/src/btree.h diff --git a/src/btree.h b/src/btree.h index 3f7aecb..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. */ @@ -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 *