From: Ricardo Markiewicz Date: Mon, 3 Oct 2005 04:10:58 +0000 (+0000) Subject: Agrego test de borrado de una hoja. X-Git-Tag: 1_0-pre1~63 X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/commitdiff_plain/d9f6b6c969656b47f1e6a051cfc65959bd5c069f?ds=inline Agrego test de borrado de una hoja. --- diff --git a/src/Makefile b/src/Makefile index 2bcafd6..a496d72 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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) diff --git a/src/btree.h b/src/btree.h index e67c7cf..df427ed 100644 --- a/src/btree.h +++ b/src/btree.h @@ -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 index 0000000..a6148f2 --- /dev/null +++ b/src/main_con_delete.cpp @@ -0,0 +1,57 @@ + + +#include "btree.h" +#include "clave_fija.h" +#include "random.h" + +int main (int argc, char *argv[]) +{ + std::list lst; + + BTree tree ("test.idx", 512); + + + Random::Init (); + + Random::Ints (lst, 10); + + std::list::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; +} +