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

Annotation of /queensgui/src/containerlist.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6 - (hide annotations) (download)
Fri Jul 20 09:54:09 2007 UTC (16 years, 10 months ago) by torben
File size: 2802 byte(s)
No need for config control of this IDE-generated file


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 "containerlist.h"
21 torben 1
22 torben 4 ContainerList::ContainerList(GUIUpdate* update)
23 torben 1 : SolutionContainer(update)
24     {
25     total = -1;
26     }
27    
28    
29 torben 4 ContainerList::~ContainerList()
30 torben 1 {
31     }
32    
33    
34 torben 4 int ContainerList::numSolutions()
35 torben 1 {
36     return solutions.size();
37     }
38    
39 torben 4 int ContainerList::totalSolutions()
40 torben 1 {
41     return total;
42     }
43    
44    
45 torben 4 void ContainerList::uniqueSolutions()
46 torben 1 {
47     for (int i=1;i<=4;i++) {
48     if (m_halt)
49     return;
50     uniqueSolutionsWorker(i,false);
51     uniqueSolutionsWorker(i,true);
52     }
53     }
54    
55    
56 torben 4 void ContainerList::uniqueSolutionsWorker(int rot,bool mirror)
57 torben 1 {
58     int match_count;
59    
60     if (total == -1)
61     total = solutions.size();
62    
63     for (ListIt i=solutions.begin(); i != solutions.end(); i++) {
64     if (m_halt)
65     return;
66     match_count = 0;
67 torben 6
68     std::auto_ptr<Solution> tmp ( (*i)->copy() );
69 torben 1 if (mirror)
70 torben 2 tmp->mirror();
71 torben 1 for (int k=0;k<rot;k++)
72 torben 2 tmp->rotate90();
73 torben 1
74     //unders�g kun resten af m�ngden, start ved i+1
75     ListIt j =i;
76     j++;
77     for ( ; j!=solutions.end();j++)
78     {
79 torben 2 if ( *tmp == *(*j) )
80 torben 1 {
81     solutions.erase(j);
82     m_uniqueRemoved++;
83     m_update->duplicateRemoved();
84     break;
85     }
86     }
87     }
88     }
89    
90    
91 torben 4 void ContainerList::addSolution(Solution* sol)
92 torben 1 {
93 torben 6 solutions.push_back(boost::shared_ptr<Solution>(sol));
94 torben 1 }
95    
96 torben 4 Solution* ContainerList::solution(int index)
97 torben 1 {
98     int count=0;
99     ListIt it;
100    
101     for (it = solutions.begin(); it != solutions.end(); it++, count++) {
102     if (count == index) {
103     break;
104     }
105     }
106 torben 6 return (*it).get();
107 torben 1 }

Properties

Name Value
svn:eol-style native
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20