Repository navigation
Expand file tree
/
Copy pathopenmap.cpp
More file actions
91 lines (66 loc) · 1.7 KB
/
Copy pathopenmap.cpp
File metadata and controls
91 lines (66 loc) · 1.7 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
#include <iostream>
#include <stdlib.h>
#include "seqLinearList.hpp"
#include "OpenMap.hpp"
#include "DoubleHashMap.hpp"
#include "Dictionary.hpp"
using namespace std;
using namespace cs202;
int main()
{
OpenMap<int,int> ht(3);
// ht.put(7,98);
// ht.put(2,56);
// ht.put(3,500);
// ht.put(505,0);
// ht.put(7,92);
// ht.put(10,57);
// ht.print();
// ht.remove(7);
// ht.print();
// cout<<ht[7];
// ht.print();
while(1)
{
cout<<"\n1: Insert into hash table "<<endl;
cout<<"2: Delete from hash table "<<endl;
cout<<"3: Get value for a given key"<<endl;
cout<<"4: Check availability of a key"<<endl;
cout<<"5: Size of hash map"<<endl;
cout<<"6: Print hash table"<<endl;
cout<<"7: Check capacity"<<endl;
cout<<"8: Exit"<<endl;
int choice,key,value;
cin>>choice;
switch(choice)
{
case 1: cout<<"\nEnter Key: ";
cin>>key;
cout<<"Enter Value: ";
cin>>value;
ht.put(key,value);
break;
case 2: cout<<"\nEnter Key: ";
cin>>key;
ht.remove(key);
break;
case 3: cout<<"\nEnter Key: ";
cin>>key;
cout<<"The value for given key is :"<<ht.get(key);
break;
case 4: cout<<"\nEnter Key: ";
cin>>key;
ht.has(key);
break;
case 5: cout<<"\nSize is :"<<ht.get_size();
break;
case 6: ht.print();
break;
case 7: cout<<ht.get_capacity()<<endl;
break;
case 8: exit(0);
default: cout<<"\nWrong input! Enter again."<<endl;
}
}
return 0;
}