X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/113597e3c369b18fa4e73a0b9744398a0e9e0a79..c03f170abe6adaa72ff04318cb178cdcfb635f19:/src/btree.cpp diff --git a/src/btree.cpp b/src/btree.cpp index d1fbab3..8803d20 100644 --- a/src/btree.cpp +++ b/src/btree.cpp @@ -66,6 +66,11 @@ void BTree::AddKey (const Clave &k) std::cout << "__NO__ hay lugar para meter la clave" << std::endl; } + + WriteKeys (root, root_header, node_keys); + WriteNodoHeader (root, &root_header); + write_block (root, 0); + delete [] root; } @@ -109,3 +114,18 @@ std::list BTree::ReadKeys (uchar *node, BTreeNodeHeader &node_header) return keys; } +void BTree::WriteKeys (uchar *node, BTreeNodeHeader &node_header, std::list &keys) +{ + std::list::iterator it = keys.begin (); + + node += sizeof (BTreeNodeHeader); + + while (it != keys.end ()) { + Clave *c = (*it); + memcpy (node, c->ToArray(), c->Size ()); + node += c->Size (); + it++; + } + + /* TODO : incrementar node_header.item_count aca o fuera de este metodo? */ +}