1 |
torben |
1 |
/*************************************************************************** |
2 |
|
|
* Copyright (C) 2005 by Torben Nielsen * |
3 |
|
|
* torben@t-hoerup.dk * |
4 |
|
|
* * |
5 |
|
|
* This program is free software; you can redistribute it and/or modify * |
6 |
|
|
* it under the terms of the GNU General Public License as published by * |
7 |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
8 |
|
|
* (at your option) any later version. * |
9 |
|
|
* * |
10 |
|
|
* This program is distributed in the hope that it will be useful, * |
11 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 |
|
|
* GNU General Public License for more details. * |
14 |
|
|
* * |
15 |
|
|
* You should have received a copy of the GNU General Public License * |
16 |
|
|
* along with this program; if not, write to the * |
17 |
|
|
* Free Software Foundation, Inc., * |
18 |
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 |
|
|
***************************************************************************/ |
20 |
torben |
4 |
#include "containermnvector.h" |
21 |
torben |
1 |
|
22 |
torben |
6 |
#include <memory> |
23 |
|
|
|
24 |
torben |
4 |
ContainerMNVector::ContainerMNVector(GUIUpdate* update) |
25 |
|
|
: ContainerVector(update) |
26 |
torben |
1 |
{ |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
|
30 |
torben |
4 |
ContainerMNVector::~ContainerMNVector() |
31 |
torben |
1 |
{ |
32 |
|
|
} |
33 |
|
|
|
34 |
torben |
4 |
void ContainerMNVector::uniqueSolutions() |
35 |
torben |
1 |
{ |
36 |
torben |
6 |
std::vector< boost::shared_ptr<Solution> > buf; |
37 |
torben |
1 |
buf.reserve(solutions.size() / 10); |
38 |
|
|
for (unsigned int i=0; i<solutions.size(); i++) { |
39 |
|
|
if (m_halt) |
40 |
|
|
break; |
41 |
|
|
|
42 |
|
|
unsigned int j; |
43 |
|
|
for (j=0; j<buf.size(); j++) { |
44 |
|
|
if (m_halt) |
45 |
|
|
break; |
46 |
torben |
6 |
std::auto_ptr<Solution> tmp ( solutions[i]->copy() ) ; |
47 |
torben |
1 |
|
48 |
torben |
2 |
if (*tmp == *buf[j]) |
49 |
torben |
1 |
break; |
50 |
torben |
2 |
tmp->rotate90(); |
51 |
torben |
1 |
|
52 |
torben |
6 |
if ( *tmp == *buf[j]) |
53 |
torben |
1 |
break; |
54 |
|
|
|
55 |
torben |
2 |
tmp->rotate90(); |
56 |
|
|
if (*tmp == *buf[j]) |
57 |
torben |
1 |
break; |
58 |
|
|
|
59 |
torben |
2 |
tmp->rotate90(); |
60 |
|
|
if (*tmp == *buf[j]) |
61 |
torben |
1 |
break; |
62 |
|
|
|
63 |
torben |
2 |
tmp->mirror(); |
64 |
|
|
if (*tmp == *buf[j]) |
65 |
torben |
1 |
break; |
66 |
|
|
|
67 |
torben |
2 |
tmp->rotate90(); |
68 |
|
|
if (*tmp == *buf[j]) |
69 |
torben |
1 |
break; |
70 |
|
|
|
71 |
torben |
2 |
tmp->rotate90(); |
72 |
|
|
if (*tmp == *buf[j]) |
73 |
torben |
1 |
break; |
74 |
|
|
|
75 |
torben |
2 |
tmp->rotate90(); |
76 |
|
|
if (*tmp == *buf[j]) |
77 |
torben |
1 |
break; |
78 |
|
|
} |
79 |
|
|
if ( j == buf.size() ) |
80 |
|
|
{ // hvis j==buf.size() fandt vi ingen duplicates i buf |
81 |
|
|
buf.push_back( solutions[i] ); |
82 |
|
|
m_uniqueRemoved++; |
83 |
|
|
m_update->duplicateRemoved(); |
84 |
|
|
} |
85 |
|
|
} |
86 |
|
|
solutions = buf; |
87 |
torben |
2 |
|
88 |
torben |
1 |
} |