/[projects]/queensgui/src/containerminimalvector.cpp
ViewVC logotype

Contents of /queensgui/src/containerminimalvector.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13 - (show annotations) (download)
Sun Jul 22 20:19:43 2007 UTC (16 years, 9 months ago) by torben
File size: 2959 byte(s)
Added another (but unfortunately not more effecient) container class.

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 #include "containerminimalvector.h"
21
22 #include <memory>
23 #include "solution.h"
24
25 ContainerMinimalVector::ContainerMinimalVector(GUIUpdate* update): SolutionContainer(update)
26 {
27 m_total = 0;
28 }
29
30
31 ContainerMinimalVector::~ContainerMinimalVector()
32 {
33 }
34
35
36 int ContainerMinimalVector::getUniqueRemoved()
37 {
38 return m_total - m_solutions.size();
39 }
40
41 int ContainerMinimalVector::numSolutions()
42 {
43 return m_solutions.size();
44 }
45
46 int ContainerMinimalVector::totalSolutions()
47 {
48 return m_total;
49 }
50
51 Solution* ContainerMinimalVector::solution(int index)
52 {
53 return m_solutions[index].get();
54 }
55
56 void ContainerMinimalVector::addSolution(Solution* sol)
57 {
58 std::auto_ptr<Solution> tmp( sol->copy() );
59 bool found = false;
60
61 for (VIt it = m_solutions.begin(); it != m_solutions.end(); it++)
62 {
63 tmp->rotate90();
64 if ( *tmp == *(*it))
65 {
66 found = true;
67 break;
68 }
69
70
71 tmp->rotate90();
72 if ( *tmp == *(*it))
73 {
74 found = true;
75 break;
76 }
77
78 tmp->rotate90();
79 if ( *tmp == *(*it))
80 {
81 found = true;
82 break;
83 }
84 tmp->rotate90();
85 if ( *tmp == *(*it))
86 {
87 found = true;
88 break;
89 }
90 tmp->mirror();
91 if ( *tmp == *(*it))
92 {
93 found = true;
94 break;
95 }
96
97 tmp->rotate90();
98 if ( *tmp == *(*it))
99 {
100 found = true;
101 break;
102 }
103 tmp->rotate90();
104 if ( *tmp == *(*it))
105 {
106 found = true;
107 break;
108 }
109 tmp->rotate90();
110 if ( *tmp == *(*it))
111 {
112 found = true;
113 break;
114 }
115 }
116 if (found == false)
117 {
118 m_solutions.push_back( boost::shared_ptr<Solution>(sol) );
119 m_total++;
120 }
121 }
122
123 void ContainerMinimalVector::uniqueSolutions()
124 {
125 // Do nothing
126 }

  ViewVC Help
Powered by ViewVC 1.1.20