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

Annotation of /queensgui/src/solutionint.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9 - (hide annotations) (download)
Fri Jul 20 16:58:49 2007 UTC (16 years, 10 months ago) by torben
File size: 2639 byte(s)
Silenced a warning

1 torben 5 /***************************************************************************
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 "solutionint.h"
21    
22     SolutionInt::SolutionInt(int size)
23     {
24     m_size = size;
25    
26     for (int i=0; i<size; i++)
27     {
28     m_matrix[i] = -1;
29     }
30     }
31    
32    
33     SolutionInt::~SolutionInt()
34     {
35     }
36    
37     SolutionInt::SolutionInt(const SolutionInt& input)
38     : Solution()
39     {
40     m_size = input.m_size;
41     for (int i=0; i<m_size; i++)
42     m_matrix[i] = input.m_matrix[i];
43     }
44    
45 torben 8 void SolutionInt::set(unsigned char input[MAX_SIZE])
46     {
47     for (int i=0; i<m_size; i++)
48     m_matrix[i] = input[i];
49     }
50    
51 torben 5 bool SolutionInt::getMatrix(int x, int y)
52     {
53     return (m_matrix[x] == y);
54     }
55    
56     void SolutionInt::setMatrix(int x, int y, bool val)
57     {
58     if (val == true)
59     m_matrix[x] = y;
60     else
61     m_matrix[x] = -1;
62     }
63    
64     bool SolutionInt::operator ==(const Solution& s)
65     {
66     const SolutionInt& sol = dynamic_cast<const SolutionInt&>(s);
67     for (int i=0; i<m_size; i++)
68     if (m_matrix[i] != sol.m_matrix[i])
69     return false;
70     return true;
71     }
72 torben 8
73 torben 5 Solution* SolutionInt::copy()
74     {
75     return new SolutionInt(*this);
76     }
77    
78     void SolutionInt::mirror()
79     {
80 torben 8 unsigned char temp[MAX_SIZE];
81     for (int i=0; i<m_size; i++)
82     temp[i] = (m_size-1) - m_matrix[i];
83     set( temp );
84 torben 5 }
85    
86 torben 8
87 torben 5 void SolutionInt::rotate90()
88     {
89 torben 8 unsigned char temp[MAX_SIZE];
90 torben 9
91 torben 8 for (int i=0; i<m_size; i++)
92     {
93     int x = i;
94     int y = m_matrix[i];
95    
96 torben 9 temp[y] = (m_size-1) - x;
97 torben 8 }
98    
99     set( temp);
100 torben 5 }

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.20