4 #include "clave_variable.h"
9 void generar_aleatorio (std::list<std::string> &lst, uint cant);
11 int main (int argc, char *argv[])
13 BTree tree ("test.idx", 128, BTree::KEY_VARIABLE);
16 printf ("Falta parametro cantidad de elementos a agregar\n");
20 std::list<std::string> lst;
21 generar_aleatorio (lst, atoi(argv[1]));
23 std::list<std::string>::iterator it = lst.begin ();
24 while (it != lst.end ()) {
27 std::cout << "Agregando " << (*it) << std::endl;
33 while (it != lst.end ()) {
37 std::cout << (*it) << " encontrada\n";
39 std::cout << (*it) << " NO encontrada\n";
46 void get_file (const char *f, std::map<int,std::string> &out, int &cant)
48 std::ifstream reader (f);
52 while (!reader.eof ()) {
53 reader.getline (l, 100);
54 out[cant] = std::string (l);
60 void generar_aleatorio (std::list<std::string> &lst, uint n)
62 std::map<int, std::string> productos;
63 std::map<int, std::string> marcas;
64 int productos_cant, marcas_cant;
66 get_file ("productos.txt", productos, productos_cant);
67 get_file ("marcas.txt", marcas, marcas_cant);
71 /* TODO : Evitar repetidos */
72 for (uint i=0; i < n; i++) {
73 random1 = 1 + (int)(productos_cant * (float)rand () / (RAND_MAX + 1.0f));
74 random2 = 1 + (int)(marcas_cant * (float)rand () / (RAND_MAX + 1.0f));
76 lst.push_back (productos[random1-1] + " " + marcas[random2-1]);