-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
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)
--- /dev/null
+
+
+#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;
+}
+