Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <chrono>
- #include <algorithm>
- #include <utility>
- #include "sorterhelper.h"
- #include "sorter.h"
- using namespace std;
- using namespace std::chrono;
- SorterHelper::SorterHelper(){}
- void SorterHelper::MysteryClassA(vector<int>&myVector)
- {
- Sorter<int>*mySort = new MysterySorterA<int>;
- mySort->setData(myVector);
- auto startA = high_resolution_clock::now();
- mySort->sort();
- auto stopA = high_resolution_clock::now();
- std::chrono::duration<double, std::micro> durationA = stopA - startA;
- findTimeA(durationA.count());
- runtimes.push_back(durationA.count());
- originalIndex.push_back(0);
- delete mySort;
- }
- void SorterHelper::MysteryClassB(vector<int>&myVector)
- {
- Sorter<int>*mySort = new MysterySorterB<int>;
- mySort->setData(myVector);
- auto startB = high_resolution_clock::now();
- mySort->sort();
- auto stopB = high_resolution_clock::now();
- std::chrono::duration<double, std::micro> durationB = stopB - startB;
- findTimeB(durationB.count());
- runtimes.push_back(durationB.count());
- originalIndex.push_back(1);
- delete mySort;
- }
- void SorterHelper::MysteryClassC(vector<int>&myVector)
- {
- Sorter<int>*mySort = new MysterySorterC<int>;
- mySort->setData(myVector);
- auto startC = high_resolution_clock::now();
- mySort->sort();
- auto stopC = high_resolution_clock::now();
- std::chrono::duration<double, std::micro> durationC = stopC - startC;
- findTimeC(durationC.count());
- runtimes.push_back(durationC.count());
- originalIndex.push_back(2);
- delete mySort;
- }
- void SorterHelper::MysteryClassD(vector<int>&myVector)
- {
- Sorter<int>*mySort = new MysterySorterD<int>;
- mySort->setData(myVector);
- auto startD = high_resolution_clock::now();
- mySort->sort();
- auto stopD = high_resolution_clock::now();
- std::chrono::duration<double, std::micro> durationD = stopD - startD;
- findTimeD(durationD.count());
- runtimes.push_back(durationD.count());
- originalIndex.push_back(3);
- delete mySort;
- }
- void SorterHelper::MysteryClassE(vector<int>&myVector)
- {
- Sorter<int>*mySort = new MysterySorterE<int>;
- mySort->setData(myVector);
- auto startE = high_resolution_clock::now();
- mySort->sort();
- auto stopE = high_resolution_clock::now();
- std::chrono::duration<double, std::micro> durationE = stopE - startE;
- findTimeE(durationE.count());
- runtimes.push_back(durationE.count());
- originalIndex.push_back(4);
- delete mySort;
- }
- void SorterHelper::findTimeA(double durationA)
- {
- //cout << "MysteryClassA duration: " << durationA << endl;
- }
- void SorterHelper::findTimeB(double durationB)
- {
- //cout << "MysteryClassB duration: " << durationB << endl;
- }
- void SorterHelper::findTimeC(double durationC)
- {
- //cout << "MysteryClassC duration: " << durationC << endl;
- }
- void SorterHelper::findTimeD(double durationD)
- {
- //cout << "MysteryClassD duration: " << durationD << endl;
- }
- void SorterHelper::findTimeE(double durationE)
- {
- //cout << "MysteryClassE duration: " << durationE << endl;
- //cout << endl;
- }
- void SorterHelper::determineSort()
- {
- vector<pair<double, int>>match;
- string sort1, sort2, sort3, sort4, sort5;
- for(int i = 0; i < 5; i++)
- {
- match.push_back(make_pair(runtimes[i],originalIndex[i]));
- cout << match[i].first << "\t" << match[i].second << endl;
- }
- sort(match.begin(),match.end());
- cout << endl;
- for(int i = 0; i < 5; i++)
- {
- cout << match[i].first << "\t" << match[i].second << "\t" <<i<< endl;
- }
- cout << endl;
- for(int i = 0; i < 5; i++)
- {
- if(i==0){
- cout << "MysterySortA is ";
- }
- if(i==1){
- cout << "MysterySortB is ";
- }
- if(i==2){
- cout << "MysterySortC is ";
- }
- if(i==3){
- cout << "MysterySortD is ";
- }
- if(i==4){
- cout << "MysterySortE is ";
- }
- for(int j = 0; j < 5; j++)
- {
- if(match[j].second == i)
- {
- if(j == 0){
- sort1 = "QuickSort";
- cout << sort1 << endl;
- }
- if(j == 1){
- sort2 = "MergeSort";
- cout << sort2 << endl;;
- }
- if(j == 2){
- sort3 = "InsertSort";
- cout << sort3 << endl;
- }
- if(j == 3){
- sort4 = "SelectionSort";
- cout << sort4 << endl;
- }
- if(j == 4){
- sort5 = "BubbleSort";
- cout << sort5 << endl;
- }
- }
- }
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement