From: Ricardo Markiewicz Date: Tue, 13 Sep 2005 17:36:36 +0000 (+0000) Subject: Mas codigo de AddKey X-Git-Tag: 1_0-pre1~140 X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/commitdiff_plain/81763ef5215161bd08100ea98910ae6bb093aea6?ds=sidebyside Mas codigo de AddKey --- diff --git a/src/btree.cpp b/src/btree.cpp index cf01b2c..38873c6 100644 --- a/src/btree.cpp +++ b/src/btree.cpp @@ -55,7 +55,7 @@ void BTree::AddKey (const Clave &k) Clave* BTree::AddKeyR (const Clave *k, uint node_num) { - Clave *kout; + Clave *kout = NULL; std::list node_keys; /* Leo el nodo raiz para empezar a agregar */ @@ -67,18 +67,23 @@ Clave* BTree::AddKeyR (const Clave *k, uint node_num) if (node_header.free_space >= k->Size ()) { /* TODO : Insertar ordenado */ - //node_keys.push_back (BTreek->Clone ()); + /* Siempre se agrega en una hoja */ + node_keys.push_back (BTreeLeafData (k->Clone ())); + + WriteKeys (node, node_header, node_keys); + WriteNodoHeader (node, &node_header); + WriteBlock (node, node_num); + delete [] node; } else { /* Split */ + /* Lo que debe pasar : + * 1) Separar N/2 claves en "nodo" + * 2) Separar N/2-1 claves en un nuevo nodo + * 3) kout = clave del medio y mandarla al padre + */ + std::cout << "SPLIT" << std::endl; } - - WriteKeys (node, node_header, node_keys); - WriteNodoHeader (node, &node_header); - WriteBlock (node, node_num); - - delete [] node; - return kout; }