From de3ca1e5273df618c6cc1520a5cbf304f4ac74f6 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Mon, 24 Oct 2005 16:56:22 +0000 Subject: [PATCH] Saco ejemplos viejos. --- src/Makefile | 8 +---- src/main_con_delete.cpp | 76 --------------------------------------- src/main_variable.cpp | 79 ----------------------------------------- 3 files changed, 1 insertion(+), 162 deletions(-) delete mode 100644 src/main_con_delete.cpp delete mode 100644 src/main_variable.cpp diff --git a/src/Makefile b/src/Makefile index de39baf..80c2391 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,4 +1,4 @@ -TARGETS=btree btree_variable btree_delete libbtree.a +TARGETS=btree libbtree.a CXXFLAGS=-Wall -g #Descomentar si se quiere agregar informacion para profiling @@ -13,12 +13,6 @@ all: $(TARGETS) btree: main.o $(BTREE_COMMON) g++ $(PROF) -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) - libbtree.a: $(BTREE_COMMON) $(AR) cru libbtree.a $(BTREE_COMMON) diff --git a/src/main_con_delete.cpp b/src/main_con_delete.cpp deleted file mode 100644 index baa1d78..0000000 --- a/src/main_con_delete.cpp +++ /dev/null @@ -1,76 +0,0 @@ - - -#include "btree.h" -#include "clave_fija.h" -#include "random.h" - -int main (int argc, char *argv[]) -{ - std::list lst; - - BTree tree ("test.idx", 64); - - - Random::Init (); - - //Random::Ints (lst, 10); - for (int i=0; i<14; i++) - lst.push_back (i); - - std::list::iterator it = lst.begin (); - while (it != lst.end ()) { - ClaveFija c(*it); - - std::cout << "Agregando " << (*it) << std::endl; - tree.AddKey (c); - it++; - } - std::cout << "\n\n"; - tree.PrintNode (0); - std::cout << "\n\n"; - tree.PrintNode (1); - std::cout << "\n\n"; - tree.PrintNode (2); - std::cout << "\n\n"; - { - ClaveFija c(6); - tree.DelKey (c); - } - tree.PrintNode (0); - std::cout << "\n\n"; - tree.PrintNode (1); - std::cout << "\n\n"; - tree.PrintNode (2); - return 0; - - 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; -} - diff --git a/src/main_variable.cpp b/src/main_variable.cpp deleted file mode 100644 index 477f632..0000000 --- a/src/main_variable.cpp +++ /dev/null @@ -1,79 +0,0 @@ - - -#include "btree.h" -#include "clave_variable.h" -#include -#include -#include - -void generar_aleatorio (std::list &lst, uint cant); - -int main (int argc, char *argv[]) -{ - BTree tree ("test.idx", 128, BTree::KEY_VARIABLE); - - if (argc != 2) { - printf ("Falta parametro cantidad de elementos a agregar\n"); - return 1; - } - - std::list lst; - generar_aleatorio (lst, atoi(argv[1])); - - std::list::iterator it = lst.begin (); - while (it != lst.end ()) { - ClaveVariable c(*it); - - std::cout << "Agregando " << (*it) << std::endl; - tree.AddKey (c); - it++; - } - - it = lst.begin (); - while (it != lst.end ()) { - ClaveVariable c(*it); - - if (tree.FindKey (c)) - std::cout << (*it) << " encontrada\n"; - else - std::cout << (*it) << " NO encontrada\n"; - it++; - } - - return 0; -} - -void get_file (const char *f, std::map &out, int &cant) -{ - std::ifstream reader (f); - cant = 0; - char l[100]; - - while (!reader.eof ()) { - reader.getline (l, 100); - out[cant] = std::string (l); - cant++; - } -} - - -void generar_aleatorio (std::list &lst, uint n) -{ - std::map productos; - std::map marcas; - int productos_cant, marcas_cant; - - get_file ("productos.txt", productos, productos_cant); - get_file ("marcas.txt", marcas, marcas_cant); - - srand (time (NULL)); - int random1, random2; - /* TODO : Evitar repetidos */ - for (uint i=0; i < n; i++) { - random1 = 1 + (int)(productos_cant * (float)rand () / (RAND_MAX + 1.0f)); - random2 = 1 + (int)(marcas_cant * (float)rand () / (RAND_MAX + 1.0f)); - - lst.push_back (productos[random1-1] + " " + marcas[random2-1]); - } -} - -- 2.43.0