]> git.llucax.com Git - z.facultad/75.52/treemulator.git/commitdiff
Agrego test de borrado de una hoja.
authorRicardo Markiewicz <rmarkie@fi.uba.ar>
Mon, 3 Oct 2005 04:10:58 +0000 (04:10 +0000)
committerRicardo Markiewicz <rmarkie@fi.uba.ar>
Mon, 3 Oct 2005 04:10:58 +0000 (04:10 +0000)
src/Makefile
src/btree.h
src/main_con_delete.cpp [new file with mode: 0644]

index 2bcafd625ba327d23a9cd1d82f31765491e13282..a496d72c8df500cc319803496713b882a32dc1f5 100644 (file)
@@ -1,4 +1,4 @@
-TARGETS=btree btree_variable libbtree.a
+TARGETS=btree btree_variable btree_delete libbtree.a
 CXXFLAGS=-Wall -g
 
 BTREE_COMMON=btree.o clave_fija.o btree_data.o clave_variable.o
@@ -8,6 +8,9 @@ all: $(TARGETS)
 btree: main.o $(BTREE_COMMON)
        g++ -o btree main.o $(BTREE_COMMON)
 
+btree_delete: main_con_delete.o $(BTREE_COMMON)
+       g++ -o btree_delete main_con_delete.o $(BTREE_COMMON)
+
 btree_variable: main_variable.o $(BTREE_COMMON)
        g++ -o btree_variable main_variable.o $(BTREE_COMMON)
 
index e67c7cf537fd99a4782415d11695557ab988e7db..df427edf26bfd354757f681a3c1c7b82575c2d2f 100644 (file)
@@ -143,6 +143,7 @@ class BTree {
 
 
                /* DEBUG */
+       public:
                void PrintNode (uint num);
 };
 
diff --git a/src/main_con_delete.cpp b/src/main_con_delete.cpp
new file mode 100644 (file)
index 0000000..a6148f2
--- /dev/null
@@ -0,0 +1,57 @@
+
+
+#include "btree.h"
+#include "clave_fija.h"
+#include "random.h"
+
+int main  (int argc, char *argv[])
+{
+       std::list<int> lst;
+
+       BTree tree ("test.idx", 512);
+       
+
+       Random::Init ();
+
+       Random::Ints (lst, 10);
+
+       std::list<int>::iterator it = lst.begin ();
+       while (it != lst.end ()) {
+               ClaveFija c(*it);
+
+               std::cout << "Agregando " << (*it) << std::endl;
+               tree.AddKey (c);
+               it++;
+       }
+
+       it = lst.begin ();
+       BTreeFindResult *r;
+       while (it != lst.end ()) {
+               ClaveFija c(*it);
+
+               r = tree.FindKey (c);
+               if (r) {
+                       std::cout << (*it) << " encontrada\n";
+                       delete r;
+               } else
+                       std::cout << (*it) << " NO encontrada\n";
+               it++;
+       }
+
+       it = lst.begin ();
+       while (it != lst.end ()) {
+               ClaveFija c(*it);
+
+               std::cout << "========= Borro : " << (*it)<< "============\n";
+               tree.PrintNode (0);
+               tree.DelKey (c);
+               std::cout << std::endl;
+               tree.PrintNode (0);
+               it++;
+               std::cout << "=============================\n";
+       }
+       
+
+       return 0;
+}
+