-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerator.cpp
34 lines (33 loc) · 1.23 KB
/
Generator.cpp
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
#include "Generator.hpp"
#include <random>
///////////////////////////////////////////////////////////////////////////////////////////
long int Generator::time_reseed() {
clock_::duration dur = clock_::now() - beginT;
long int seed = dur.count();
return seed;
}
///////////////////////////////////////////////////////////////////////////////////////////
bool Generator::readFileToVector(std::string filename, std::vector<std::string>& content) {
std::ifstream input(filename.c_str());
std::string linestr;
if (!input)
return false;
while (std::getline(input, linestr)) {
if (linestr.size() > 0)
content.push_back(linestr);
}
input.close();
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
bool Generator::saveVectorToFile(std::string filename, std::vector<std::string>& content) {
std::ofstream OutFile(filename);
if (!OutFile) {
return false;
};
std::ostream_iterator<std::string> output_iterator(OutFile, "\n");
std::copy(content.begin(), content.end(), output_iterator);
OutFile.close();
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////