-
Notifications
You must be signed in to change notification settings - Fork 1
/
Prac10_Hashing.cpp
50 lines (36 loc) · 1.33 KB
/
Prac10_Hashing.cpp
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
#include <iostream>
#include <random>
#include <chrono>
#include "SingleHash.h"
int main() {
SingleHash H(37);
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_real_distribution<double> dist(1.0, 1000000000.0);
std::cout << "Hashing With Chaining!!" << std::endl;
int size = 100;
long long find;
auto start1 = std::chrono::high_resolution_clock::now();
cout << "Allocating Items" << endl;
for (auto i = 0; i < size; i++) {
auto temp = (long long) (dist(mt));
if (i == 25)
find = temp;
H.insertItem(temp);
}
cout << "Items Allocated" << endl;
auto stop1 = std::chrono::high_resolution_clock::now();
auto duration1 = std::chrono::duration_cast<std::chrono::seconds>(stop1 - start1);
cout << "Item Allocation Duration: " << duration1.count() << " seconds" << endl;
H.displaySizes();
auto start2 = std::chrono::high_resolution_clock::now();
H.findNumber(find);
auto stop2 = std::chrono::high_resolution_clock::now();
auto duration2 = std::chrono::duration_cast<std::chrono::microseconds>(stop2 - start2);
cout << "Single Hash Function completed searching in " << duration2.count() << " microseconds" << endl;
// H.displayHash();
H.deleteItem(find);
H.findNumber(find);
H.displayHash();
return 0;
}