Skip to content
Snippets Groups Projects
Commit 017ad496 authored by Tamas Bunth's avatar Tamas Bunth
Browse files

print result elements in order

parent 692df17a
Branches
No related tags found
No related merge requests found
...@@ -19,6 +19,12 @@ void Processor::process(std::list<Element> list) ...@@ -19,6 +19,12 @@ void Processor::process(std::list<Element> list)
if(list.size() == 0) if(list.size() == 0)
{ {
rMatrix_.print(); rMatrix_.print();
std::cout << "Elemek: " << std::endl;
for(const auto& elem : result)
{
elem.print();
}
std::cout << "----------------------" << std::endl;
ready_ = true; ready_ = true;
return; return;
} }
...@@ -29,20 +35,21 @@ void Processor::process(std::list<Element> list) ...@@ -29,20 +35,21 @@ void Processor::process(std::list<Element> list)
auto it = list.begin(); auto it = list.begin();
while( hasMoreState || it!= list.end() ) while( hasMoreState || it!= list.end() )
{ {
Position pos{0,0}; Position pos;
success = rMatrix_.putFirst(*it, pos); success = rMatrix_.putFirst(*it, pos);
if(success) if(success)
{ {
// rMatrix_.print(); // rMatrix_.print();
result.push_back(*it);
// copy everything except current // copy everything except current
std::list<Element> copy; std::list<Element> copy;
std::copy(list.begin(), it, std::back_inserter(copy)); std::copy(list.begin(), it, std::back_inserter(copy));
copy.insert(copy.end(), std::next(it), list.end()); copy.insert(copy.end(), std::next(it), list.end());
process(std::move(copy)); process(std::move(copy));
if(ready_)
it->print();
rMatrix_.free(*it, pos); rMatrix_.free(*it, pos);
result.pop_back();
} }
hasMoreState = it->nextState(); hasMoreState = it->nextState();
......
...@@ -12,6 +12,7 @@ class Processor ...@@ -12,6 +12,7 @@ class Processor
private: private:
bool ready_ = false; bool ready_ = false;
Matrix& rMatrix_; Matrix& rMatrix_;
std::list<Element> result;
public: public:
Processor(Matrix& matrix); Processor(Matrix& matrix);
......
...@@ -18,6 +18,7 @@ enum class Direction ...@@ -18,6 +18,7 @@ enum class Direction
struct Position struct Position
{ {
std::size_t x, y; std::size_t x, y;
Position() = default;
Position(std::size_t x, std::size_t y) Position(std::size_t x, std::size_t y)
:x(x), y(y) {} :x(x), y(y) {}
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment