-TARGETS=btree btree_variable btree_delete libbtree.a
+TARGETS=btree libbtree.a
CXXFLAGS=-Wall -g
#Descomentar si se quiere agregar informacion para profiling
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)
+++ /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", 64);
-
-
- Random::Init ();
-
- //Random::Ints (lst, 10);
- for (int i=0; i<14; i++)
- lst.push_back (i);
-
- std::list<int>::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;
-}
-
+++ /dev/null
-
-
-#include "btree.h"
-#include "clave_variable.h"
-#include <list>
-#include <map>
-#include <fstream>
-
-void generar_aleatorio (std::list<std::string> &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<std::string> lst;
- generar_aleatorio (lst, atoi(argv[1]));
-
- std::list<std::string>::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<int,std::string> &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<std::string> &lst, uint n)
-{
- std::map<int, std::string> productos;
- std::map<int, std::string> 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]);
- }
-}
-