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)
if(list.size() == 0)
{
rMatrix_.print();
std::cout << "Elemek: " << std::endl;
for(const auto& elem : result)
{
elem.print();
}
std::cout << "----------------------" << std::endl;
ready_ = true;
return;
}
......@@ -29,20 +35,21 @@ void Processor::process(std::list<Element> list)
auto it = list.begin();
while( hasMoreState || it!= list.end() )
{
Position pos{0,0};
Position pos;
success = rMatrix_.putFirst(*it, pos);
if(success)
{
// rMatrix_.print();
result.push_back(*it);
// copy everything except current
std::list<Element> copy;
std::copy(list.begin(), it, std::back_inserter(copy));
copy.insert(copy.end(), std::next(it), list.end());
process(std::move(copy));
if(ready_)
it->print();
rMatrix_.free(*it, pos);
result.pop_back();
}
hasMoreState = it->nextState();
......
......@@ -12,6 +12,7 @@ class Processor
private:
bool ready_ = false;
Matrix& rMatrix_;
std::list<Element> result;
public:
Processor(Matrix& matrix);
......
......@@ -18,6 +18,7 @@ enum class Direction
struct Position
{
std::size_t x, y;
Position() = default;
Position(std::size_t x, std::size_t 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