forked from darakian/dataStructures
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSource.cpp
More file actions
54 lines (53 loc) · 1.15 KB
/
Source.cpp
File metadata and controls
54 lines (53 loc) · 1.15 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
#include "HashMap.h"
int main()
{
HashMap hash;
int key, value;
int choice;
while (1)
{
cout << "\n----------------------" << endl;
cout << "Operations on Hash Table" << endl;
cout << "\n----------------------" << endl;
cout << "1.Insert element into the table" << endl;
cout << "2.Search element from the key" << endl;
cout << "3.Delete element at a key" << endl;
cout << "4.Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter element to be inserted: ";
cin >> value;
cout << "Enter key at which element to be inserted: ";
cin >> key;
hash.Insert(key, value);
break;
case 2:
cout << "Enter key of the element to be searched: ";
cin >> key;
if (hash.Search(key) == -1)
{
cout << "No element found at key " << key << endl;
continue;
}
else
{
cout << "Element at key " << key << " : ";
cout << hash.Search(key) << endl;
}
break;
case 3:
cout << "Enter key of the element to be deleted: ";
cin >> key;
hash.Remove(key);
break;
case 4:
exit(1);
default:
cout << "\nEnter correct option\n";
}
}
return 0;
}