X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/fbf727a8d5f7eb87843eb17720eb66e51ba1707a..6d948f6bdab2bb66cd5eb8046ec67ca9b3ab76c1:/src/btree.h diff --git a/src/btree.h b/src/btree.h index 0ed4fbd..081c436 100644 --- a/src/btree.h +++ b/src/btree.h @@ -44,18 +44,20 @@ * tomar una idea simimar) */ +#include #include +#include "common.h" +#include "clave.h" /* alias para codear menos :) */ -typedef unsigned char uchar; /** Encabezado del archivo BTree */ -typedef struct _btree_file_ { +struct BTreeFileHeader { uint block_size; -} BTreeFileHeader; +}; /** Encabezado de un bloque */ -typedef struct _btree_header_ { +struct BTreeNodeHeader { /** Indica a que nivel corresponde un bloque * * nivel == 0 : una hoja @@ -71,7 +73,7 @@ typedef struct _btree_header_ { /** Cantidad de elementos en el nodo */ unsigned int item_count; -} BTreeNodeHeader; +}; /** Crea un nuevo arbol B * @@ -81,15 +83,18 @@ typedef struct _btree_header_ { */ class BTree { public: - BTree (const char *filename, unsigned int block_size, bool create_new_file = false); + BTree (const std::string &filename, unsigned int block_size, bool create_new_file = false); ~BTree (); - void AddKey (); - void DelKey (); + void AddKey (Clave &k); + void DelKey (Clave &k); private: void write_tree_header (); void write_block (uchar *block, uint num); + + uchar *ReadBlock (uint num); + void ReadNodoHeader (uchar *node, BTreeNodeHeader *header); void WriteNodoHeader (uchar *node, BTreeNodeHeader *header);