-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestTableHash.C
More file actions
executable file
·60 lines (53 loc) · 944 Bytes
/
TestTableHash.C
File metadata and controls
executable file
·60 lines (53 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include "TableHash.H"
using namespace std;
struct Persona
{
int cedula;
string nombre;
Persona()
{
cedula = 0;
nombre = "";
}
Persona(int ced,string nom)
{
cedula = ced;
nombre = nom;
}
bool operator == (Persona & p)
{
return (cedula == p.cedula);
}
int operator % (int & tam)
{
return (cedula%tam);
}
};
int main()
{
/*
* Es necesario que la clase T tenga los operadores == , = , y % definidos
*/
//Definimos la tablaHash de Persona y definimos su tamaño
TableHash<Persona> table(100);
//insertamos Personas en la tabla
for(int i = 0; i < 10; i++)
{
Persona persona(i*200,"Juan");
table.insertData(persona);
}
//buscamos una persona en la tabla
Persona per(200,"Juan");
if(table.search(per))
{
cout<<"Persona Encontrada"<<endl;
}
//eliminamos a la persona
table.deleteData(per);
if(!table.search(per))
{
cout<<"Persona Fue Eliminada"<<endl;
}
return 0;
}