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

Contents of /queensgui/src/solutionlist.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download)
Thu Jul 19 21:34:15 2007 UTC (16 years, 10 months ago) by torben
File size: 2720 byte(s)
Initial import


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 "solutionlist.h"
21
22 SolutionList::SolutionList(GUIUpdate* update)
23 : SolutionContainer(update)
24 {
25 total = -1;
26 }
27
28
29 SolutionList::~SolutionList()
30 {
31 }
32
33
34 int SolutionList::numSolutions()
35 {
36 return solutions.size();
37 }
38
39 int SolutionList::totalSolutions()
40 {
41 return total;
42 }
43
44
45 void SolutionList::uniqueSolutions()
46 {
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 void SolutionList::uniqueSolutionsWorker(int rot,bool mirror)
57 {
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 Solution tmp(*i);
68 if (mirror)
69 tmp.mirror();
70 for (int k=0;k<rot;k++)
71 tmp.rotate90();
72
73 //unders�g kun resten af m�ngden, start ved i+1
74 ListIt j =i;
75 j++;
76 for ( ; j!=solutions.end();j++)
77 {
78 if ( tmp == (*j) )
79 {
80 solutions.erase(j);
81 m_uniqueRemoved++;
82 m_update->duplicateRemoved();
83 break;
84 }
85 }
86 }
87 }
88
89
90 void SolutionList::addSolution(Solution sol)
91 {
92 solutions.push_back(sol);
93 }
94
95 Solution SolutionList::solution(int index)
96 {
97 int count=0;
98 ListIt it;
99
100 for (it = solutions.begin(); it != solutions.end(); it++, count++) {
101 if (count == index) {
102 break;
103 }
104 }
105 return *it;
106 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20