* tomar una idea simimar)
*/
+#include <iostream>
#include <string>
+#include <list>
+#include "common.h"
+#include "clave.h"
+#include "clave_fija.h"
/* alias para codear menos :) */
-typedef unsigned char uchar;
/** Encabezado del archivo BTree */
-typedef struct _btree_file_ {
- unsigned int block_size;
-} BTreeFileHeader;
+struct BTreeFileHeader {
+ uint block_size;
+};
/** Encabezado de un bloque */
-typedef struct _btree_header_ {
+struct BTreeNodeHeader {
/** Indica a que nivel corresponde un bloque
*
* nivel == 0 : una hoja
/** Cantidad de elementos en el nodo */
unsigned int item_count;
-} BTreeHeader;
+};
/** Crea un nuevo arbol B
*
*/
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 (const Clave &k);
+ void DelKey (const 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);
+
+ std::list<Clave *> ReadKeys (uchar *node, BTreeNodeHeader &node_header);
+
std::string filename;
BTreeFileHeader header;