-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsvProvider.cpp
More file actions
74 lines (70 loc) · 2.5 KB
/
Copy pathcsvProvider.cpp
File metadata and controls
74 lines (70 loc) · 2.5 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
//
// Created by Islam on 23.02.2022.
//
#include <chrono>
#include <fstream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <iostream>
using std::cin;
using std::cout;
using std::fstream;
using std::ios;
using std::ios_base;
using std::pair;
using std::string;
using std::swap;
using std::vector;
/**
* Метод для записи результатов в ячейку файла csv
*
* @param choice_sort выбранная сортировка
* @param first_loop список
* @param fout поток
*/
void writeToFile(int choice_sort,
vector<pair<pair<string, int>, pair<string, int64_t>>> &first_loop,
fstream *fout) {
bool is_size_has_written = false;
for (auto &row : first_loop) {
if (choice_sort >= 13) {
if (!is_size_has_written) {
(*fout) << row.first.first << ';' << row.first.second << ';' << row.second.second
<< ';';
is_size_has_written = true;
} else {
if (row.second.first == "HeapSort") {
(*fout) << row.second.second << std::endl;
is_size_has_written = false;
} else {
(*fout) << row.second.second << ';';
}
}
} else {
(*fout) << row.first.first << ';' << row.first.second << ';' << row.second.second
<< std::endl;
}
}
}
/**
* Метод который записывает в информацию о сортировке, которую использовал пользователь.
*
* @param choice_sort массив
* @param first_loop список
* @param fout поток
*/
void writeSortNames(int choice_sort,
const vector<pair<pair<string, int>, pair<string, int64_t>>> &first_loop,
fstream *fout) {
if (choice_sort >= 13) {
(*fout) << "Mode" << ';' << "size" << ';' << "Selection Sort" << ';' << "Bubble Sort" << ';'
<< "Bubble Sort Iverson 1" << ';' << "Bubble Sort Iverson 1 and 2" << ';'
<< "Insertion Sort" << ';' << "Binary Insertion Sort" << ';' << "Counting Sort"
<< ';' << "Radix Sort" << ';' << "Merge Sort" << ';' << "QuickSort Hoare partition"
<< ';' << "QuickSort Lomuto partition" << ';' << "HeapSort" << ';' << std::endl;
} else {
(*fout) << "Mode" << ';' << "Size" << ';' << first_loop[0].second.first << std::endl;
}
}