22
This commit is contained in:
parent
53309822f7
commit
09548ce411
@ -28,6 +28,16 @@ Configuration::Configuration(int m, int n, int number_of_pieces) {
|
||||
}
|
||||
}
|
||||
|
||||
Configuration::~Configuration()
|
||||
{
|
||||
delete this->board;
|
||||
}
|
||||
/*
|
||||
Configuration::Configuration(Configuration& t)
|
||||
{
|
||||
this->board = t.board;
|
||||
}
|
||||
*/
|
||||
std::vector<Conflict> Configuration::get_conflicts()
|
||||
{
|
||||
std::vector<Conflict> conflicts;
|
||||
|
@ -41,6 +41,18 @@ namespace queens
|
||||
Board* board;
|
||||
|
||||
Configuration(int m, int n, int number_of_pieces);
|
||||
~Configuration();
|
||||
|
||||
// I could not get copy constructor and copy assignment operator to work :/
|
||||
//Configuration(Configuration& t);
|
||||
/*
|
||||
|
||||
Configuration& operator=(const Configuration& rhs)
|
||||
{
|
||||
this->board = rhs.board;
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
std::vector<Conflict> get_conflicts();
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <chrono>
|
||||
#include "queens.hh"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
void print_conflict(queens::Conflict c)
|
||||
{
|
||||
@ -8,14 +10,16 @@ void print_conflict(queens::Conflict c)
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
queens::Configuration config = queens::Configuration(8, 8, 10);
|
||||
std::vector<queens::Conflict> conflicts = config.get_conflicts();
|
||||
for (int i=0; i<conflicts.size(); i++)
|
||||
{
|
||||
std::ofstream log;
|
||||
log.open ("time.csv", std::ios::app);
|
||||
for (int k = 0; k<24*24; k++)
|
||||
{
|
||||
print_conflict(conflicts[i]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
auto t0 = std::chrono::high_resolution_clock::now();
|
||||
queens::Configuration config = queens::Configuration(24, 24, k);
|
||||
std::vector<queens::Conflict> conflicts = config.get_conflicts();
|
||||
auto t1 = std::chrono::high_resolution_clock::now();
|
||||
log << 1.0e-06 * std::chrono::duration_cast<std::chrono::microseconds>(t1-t0).count() << "\n";
|
||||
}
|
||||
log.close();
|
||||
}
|
Loading…
Reference in New Issue
Block a user