-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
80 lines (72 loc) · 3.36 KB
/
main.cpp
File metadata and controls
80 lines (72 loc) · 3.36 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
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include "Sorting.h"
#include "Sorting.cpp"
#include "Numcomparator.h"
#include "StringComparator.h"
#include <chrono>
using namespace std;
using namespace std::chrono;
int main(){
cout << "Hello World!" << endl;
string filename;
cout << "Hello, welcome to the FBI HOME LOCATIONAL WATCHLIST SYSTEM. Please enter the file name of the data base to be processed: " << endl;
cin >> filename;
ifstream FBIwatchlist;
FBIwatchlist.open(filename);
if (!FBIwatchlist) //exiting if it doesnt work
{
cout << "INVALID FILE NAME TERMINATING IMMEDIATELY";
exit(1); // terminate with error
}
int numElements = 0;
cout << "Enter the size of the data" << endl;
cin >> numElements;
Sorting<int, string, Numcomparator> myInsertionSorter1(numElements);
Sorting<string, int, StringComparator> myInsertionSorter2(numElements);
Sorting<int, string, Numcomparator> myMergeSorter1(numElements);
Sorting<string, int, StringComparator> myMergeSorter2(numElements);
Sorting<int, string, Numcomparator> myQuickSorter1(numElements);
Sorting<string, int, StringComparator> myQuickSorter2(numElements);
Sorting<int, string, Numcomparator> myQuickSort3er1(numElements);
Sorting<string, int, StringComparator> myQuickSort3er2(numElements);
Sorting<int, string, Numcomparator> myHeapSorter1(numElements);
Sorting<string, int, StringComparator> myHeapSorter2(numElements);
Sorting<int, string, Numcomparator> myShellSorter1(numElements);
Sorting<string, int, StringComparator> myShellSorter2(numElements);
int curValue;
while (FBIwatchlist >> curValue)
{
myInsertionSorter1.add( pair<int, string>(curValue, to_string(curValue) ));
myInsertionSorter2.add(pair<string, int>(to_string(curValue), curValue));
myMergeSorter1.add(pair<int, string>(curValue, to_string(curValue)));
myMergeSorter2.add(pair<string, int>(to_string(curValue), curValue));
myQuickSorter1.add(pair<int, string>(curValue, to_string(curValue)));
myQuickSorter2.add(pair<string, int>(to_string(curValue), curValue));
myQuickSort3er1.add(pair<int, string>(curValue, to_string(curValue)));
myQuickSort3er2.add(pair<string, int>(to_string(curValue), curValue));
myHeapSorter1.add(pair<int, string>(curValue, to_string(curValue)));
myHeapSorter2.add(pair<string, int>(to_string(curValue), curValue));
myShellSorter1.add(pair<int, string>(curValue, to_string(curValue)));
myShellSorter2.add(pair<string, int>(to_string(curValue), curValue));
}
high_resolution_clock::time_point t1 = high_resolution_clock::now();
myInsertionSorter1.insertionSort();
high_resolution_clock::time_point t2 = high_resolution_clock::now();
duration<double> time_span = duration_cast<duration<double>>(t2 - t1);
double ms = 100 * time_span.count();
myInsertionSorter2.insertionSort();
myMergeSorter1.mergeSort();
myMergeSorter2.mergeSort();
myQuickSorter1.quickSort();
myQuickSorter2.quickSort();
myQuickSort3er1.quickSort3();
myQuickSort3er2.quickSort();
myHeapSorter1.heapSort();
myHeapSorter2.heapSort();
myShellSorter1.shellSort();
myShellSorter2.shellSort();
return 0;
}