-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelpers.h
83 lines (72 loc) · 3.21 KB
/
Helpers.h
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
#ifndef INTERSORT_HELPERS
#define INTERSORT_HELPERS
#include <iostream>
#include <vector>
#include <random>
#include <algorithm>
#include <set>
#include <fstream>
#include <chrono>
#include <string>
static int kIndex = 0;
namespace Intersort {
void printWelcomeScreen()
{
std::cout << "-------------------------------------------------------------------------" << std::endl;
std::cout << " ██╗███╗ ██╗████████╗███████╗██████╗ ███████╗ ██████╗ ██████╗ ████████╗\n";
std::cout << " ██║████╗ ██║╚══██╔══╝██╔════╝██╔══██╗██╔════╝██╔═══██╗██╔══██╗╚══██╔══╝\n";
std::cout << " ██║██╔██╗ ██║ ██║ █████╗ ██████╔╝███████╗██║ ██║██████╔╝ ██║\n";
std::cout << " ██║██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗╚════██║██║ ██║██╔══██╗ ██║ \n";
std::cout << " ██║██║ ╚████║ ██║ ███████╗██║ ██║███████║╚██████╔╝██║ ██║ ██║ \n";
std::cout << " ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝\n";
std::cout << "-------------------------------------------------------------------------" << std::endl;
std::cout << "Version 0.0.1" << std::endl << std::endl;
}
template<typename T>
void printVector(std::vector<T> &numbers)
{
std::cout << "[";
for(auto & num : numbers)
std::cout << num << ",";
std::cout << '\b' << "]" << '\n';
}
template<typename T>
void serializeContainer(T &container, unsigned int &totalCollisions)
{
std::string filename = "reports/container-" + std::to_string(++kIndex) + ".dat";
std::ofstream file(filename.c_str());
unsigned int collisions = 0;
file << "===\n\n\n";
for(auto const & set : container)
{
file << "[";
if(!set.empty())
{
collisions = -1;
for(auto & num : set)
{
file << num << ",";
collisions++;
}
totalCollisions += collisions;
file.seekp(-1, std::ios::end);
}
file << "]\n";
}
file.seekp(0, std::ios::beg);
file << "Collisions = " << totalCollisions << "\n";
file.close();
}
template<typename T>
void serializeVector(std::vector<T> &numbers)
{
std::ofstream file("vector.dat");
for(auto const & num : numbers)
{
file << num << ",";
}
file.seekp(-1, std::ios::end);
file << " ";
}
}
#endif