17 |
* Free Software Foundation, Inc., * |
* Free Software Foundation, Inc., * |
18 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 |
***************************************************************************/ |
***************************************************************************/ |
20 |
#include "solutionvector.h" |
#include "containervector.h" |
21 |
|
|
22 |
|
#include <memory> |
23 |
|
|
24 |
|
|
25 |
SolutionVector::SolutionVector(GUIUpdate* update) : SolutionContainer(update) |
ContainerVector::ContainerVector(GUIUpdate* update) : SolutionContainer(update) |
26 |
{ |
{ |
27 |
total = -1; |
total = -1; |
28 |
} |
} |
29 |
|
|
30 |
|
|
31 |
SolutionVector::~SolutionVector() |
ContainerVector::~ContainerVector() |
32 |
{ |
{ |
33 |
} |
} |
34 |
|
|
35 |
int SolutionVector::numSolutions() |
int ContainerVector::numSolutions() |
36 |
{ |
{ |
37 |
return solutions.size(); |
return solutions.size(); |
38 |
} |
} |
39 |
|
|
40 |
int SolutionVector::totalSolutions() |
int ContainerVector::totalSolutions() |
41 |
{ |
{ |
42 |
return total; |
return total; |
43 |
} |
} |
44 |
|
|
45 |
|
|
46 |
void SolutionVector::uniqueSolutions() |
void ContainerVector::uniqueSolutions() |
47 |
{ |
{ |
48 |
for (int i=1;i<=4;i++) { |
for (int i=1;i<=4;i++) { |
49 |
if (m_halt) |
if (m_halt) |
53 |
} |
} |
54 |
} |
} |
55 |
|
|
56 |
void SolutionVector::uniqueSolutionsWorker(int rot,bool mirror) |
void ContainerVector::uniqueSolutionsWorker(int rot,bool mirror) |
57 |
{ |
{ |
58 |
int match_count; |
int match_count; |
59 |
|
|
60 |
if (total == -1) |
if (total == -1) |
61 |
total = solutions.size(); |
total = solutions.size(); |
62 |
|
|
63 |
std::vector<Solution*> buf; |
std::vector<boost::shared_ptr<Solution> > buf; |
64 |
for (unsigned int i=0; i<solutions.size(); i++) { |
for (unsigned int i=0; i<solutions.size(); i++) { |
65 |
if (m_halt) |
if (m_halt) |
66 |
return; |
return; |
67 |
match_count = 0; |
match_count = 0; |
68 |
Solution* tmp = solutions[i]->copy(); |
|
69 |
|
std::auto_ptr<Solution> tmp ( solutions[i]->copy()); |
70 |
if (mirror) |
if (mirror) |
71 |
tmp->mirror(); |
tmp->mirror(); |
72 |
for (int k=0;k<rot;k++) |
for (int k=0;k<rot;k++) |
81 |
} |
} |
82 |
if (match_count < 1) |
if (match_count < 1) |
83 |
{ |
{ |
84 |
buf.push_back(tmp); |
buf.push_back( boost::shared_ptr<Solution>(tmp->copy()) ); |
85 |
m_uniqueRemoved ++; |
m_uniqueRemoved ++; |
86 |
m_update->duplicateRemoved(); |
m_update->duplicateRemoved(); |
87 |
} |
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
void SolutionVector::addSolution(Solution* sol) |
void ContainerVector::addSolution(Solution* sol) |
95 |
{ |
{ |
96 |
solutions.push_back(sol); |
solutions.push_back( boost::shared_ptr<Solution>(sol) ); |
97 |
} |
} |
98 |
|
|
99 |
Solution* SolutionVector::solution(int index) |
Solution* ContainerVector::solution(int index) |
100 |
{ |
{ |
101 |
return solutions[index] ; |
return solutions[index].get() ; |
102 |
} |
} |
103 |
|
|