-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
84 lines (63 loc) · 2.18 KB
/
Copy pathmain.cpp
File metadata and controls
84 lines (63 loc) · 2.18 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
#include <iostream>
#include "GameDatabaseWindow.h"
#include <fstream>
#include "splay.h"
#include "heap.h"
#include "json.hpp"
#include <string>
#include <chrono>
using namespace std;
using json = nlohmann::json;
int main() {
int count = 0;
Splay splay_tree;
MaxHeap max_heap;
// Load JSON data
ifstream f("../games.json");
json data = json::parse(f);
auto splay_start = chrono::high_resolution_clock::now();
for (auto & it : data["data"]){
string game = it.at("game");
vector<string> genre = it.at("genre");
string platform = it.at("platform");
double rating = it.at("rating");
splay_tree.insertSplay(game, rating, genre, platform);
count++;
}
for (int i = 0; i < 82466; i++) {
string game = to_string(i);
vector<string> genre = {"N/A", "N/A"};
string platform = "N/A";
double rating = 10;
splay_tree.insertSplay(game, rating, genre, platform);
count++;
}
auto splay_end = chrono::high_resolution_clock::now();
chrono::duration<double> splay_build_time = splay_end - splay_start;
// Build Max Heap with timing
auto heap_start = chrono::high_resolution_clock::now();
for (auto & it : data["data"]){
string game = it.at("game");
vector<string> genre = it.at("genre");
string platform = it.at("platform");
double rating = it.at("rating");
max_heap.insertHeap(game, 0, rating, genre, platform, "-1");
}
for (int i = 0; i < 82466; i++) {
string game = to_string(i);
vector<string> genre = {"N/A", "N/A"};
string platform = "N/A";
double rating = 10;
max_heap.insertHeap(game, 0, rating, genre, platform, "-1");
}
auto heap_end = chrono::high_resolution_clock::now();
chrono::duration<double> heap_build_time = heap_end - heap_start;
// Launch GUI with both data structures and timing info
GameDatabaseWindow window(1000, 750, splay_tree, max_heap,
splay_build_time.count(), heap_build_time.count());
window.run();
cout << endl;
cout << "Node Count: " << count << endl;
cout << endl;
return 0;
}