4 #include "clave_fija.h"
6 void generar_random (std::list<int> &lst, uint n);
8 int main (int argc, char *argv[])
12 BTree tree ("test.idx", 64);
15 printf ("Falta parametro cantidad de elementos a agregar\n");
19 generar_random (lst, atoi(argv[1]));
21 std::list<int>::iterator it = lst.begin ();
22 while (it != lst.end ()) {
25 std::cout << "Agregando " << (*it) << std::endl;
31 while (it != lst.end ()) {
35 std::cout << (*it) << " encontrada\n";
37 std::cout << (*it) << " NO encontrada\n";
44 void generar_random (std::list<int> &lst, uint n)
46 /* Genero N numeros aleatorios entre -3*n y 3*n */
47 bool *numeros = new bool [6*n+1];
50 memset (numeros, 0, (6*n+1)*sizeof (bool));
53 for (uint i=0; i < n; i++) {
55 random = 1 + (int)(6.0f * n * rand () / (RAND_MAX + 1.0f) - 3.0f * n);
56 std::cout << random << std::endl;
57 } while (numeros[random + 3 * n] == true);
58 numeros[random + 3 * n] = true;
59 lst.push_back (random);