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

Diff of /queensgui/src/containervector.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

queensgui/src/solutionvector.cpp revision 1 by torben, Thu Jul 19 21:34:15 2007 UTC queensgui/src/containervector.cpp revision 6 by torben, Fri Jul 20 09:54:09 2007 UTC
# Line 17  Line 17 
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)
# Line 52  void SolutionVector::uniqueSolutions() Line 53  void SolutionVector::uniqueSolutions()
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]);                  
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++)
73                          tmp.rotate90();                          tmp->rotate90();
74    
75                  //unders�g kun resten af m�ngden, start ved i                  //unders�g kun resten af m�ngden, start ved i
76                  for (unsigned int j=i+1; j<solutions.size();j++) {                  for (unsigned int j=i+1; j<solutions.size();j++) {
77                          if ( tmp == solutions[j] ) {                          if ( *tmp == *solutions[j] ) {
78                                  match_count++;                                  match_count++;
79                                  break;                                  break;
80                          }                          }
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                  }                  }
# Line 89  void SolutionVector::uniqueSolutionsWork Line 91  void SolutionVector::uniqueSolutionsWork
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    

Legend:
Removed from v.1  
changed lines
  Added in v.6

  ViewVC Help
Powered by ViewVC 1.1.20