MCPcopy Create free account
hub / github.com/SR-Sunny-Raj/Hacktoberfest2021-DSA / main

Function main

08. Hashing/HashingArrayProblem.cpp:71–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69 }
70};
71int main() {
72 HashMapTable hash;
73 int k, v;
74 int c;
75 while (1) {
76 cout<<"1.Insert element into the table"<<endl;
77 cout<<"2.Search element from the key"<<endl;
78 cout<<"3.Delete element at a key"<<endl;
79 cout<<"4.Exit"<<endl;
80 cout<<"Enter your choice: ";
81 cin>>c;
82 switch(c) {
83 case 1:
84 cout<<"Enter element to be inserted: ";
85 cin>>v;
86 cout<<"Enter key at which element to be inserted: ";
87 cin>>k;
88 hash.Insert(k, v);
89 break;
90 case 2:
91 cout<<"Enter key of the element to be searched: ";
92 cin>>k;
93 if (hash.SearchKey(k) == -1) {
94 cout<<"No element found at key "<<k<<endl;
95 continue;
96 } else {
97 cout<<"Element at key "<<k<<" : ";
98 cout<<hash.SearchKey(k)<<endl;
99 }
100 break;
101 case 3:
102 cout<<"Enter key of the element to be deleted: ";
103 cin>>k;
104 hash.Remove(k);
105 break;
106 case 4:
107 exit(1);
108 default:
109 cout<<"\nEnter correct option\n";
110 }
111 }
112 return 0;
113}
114
115
116

Callers

nothing calls this directly

Calls 3

InsertMethod · 0.45
SearchKeyMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected