-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashTable.cpp
More file actions
94 lines (74 loc) · 1.85 KB
/
Copy pathHashTable.cpp
File metadata and controls
94 lines (74 loc) · 1.85 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "HashTable.h"
int main()
{
std::cout
<< "===== HASHTABELLE 1 "
<< "(Hash-Funktion 1) ====="
<< std::endl;
HashTable table1(10, hashFunction1);
/*
* 5 Eintraege einfuegen.
*/
table1.insert("Anna", "0664123456");
table1.insert("Peter", "0664234567");
table1.insert("Maria", "0664345678");
table1.insert("Stefan", "0664456789");
table1.insert("Julia", "0664567890");
std::cout
<< "\nInhalt der Tabelle:"
<< std::endl;
table1.printTable();
std::cout
<< "\n===== HASHTABELLE 2 "
<< "(Hash-Funktion 2) ====="
<< std::endl;
HashTable table2(10, hashFunction2);
table2.insert("Anna", "0664123456");
table2.insert("Peter", "0664234567");
table2.insert("Maria", "0664345678");
table2.insert("Stefan", "0664456789");
table2.insert("Julia", "0664567890");
std::cout
<< "\nInhalt der Tabelle:"
<< std::endl;
table2.printTable();
/*
* Nach einem Element suchen.
*/
PhonebookEntry result;
std::cout
<< "\nSuche nach Peter:"
<< std::endl;
if(table2.search("Peter", result))
{
std::cout
<< "Gefunden: "
<< result.key
<< " -> "
<< result.value
<< std::endl;
}
else
{
std::cout
<< "Nicht gefunden."
<< std::endl;
}
/*
* Erstes Element loeschen.
*/
std::cout
<< "\nLoesche Maria:"
<< std::endl;
table2.remove("Maria");
table2.printTable();
/*
* Zweites Element loeschen.
*/
std::cout
<< "\nLoesche Anna:"
<< std::endl;
table2.remove("Anna");
table2.printTable();
return 0;
}