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

Contents of /queensgui/src/solution.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 655 - (show annotations) (download)
Fri Apr 23 05:57:28 2010 UTC (14 years ago) by torben
File size: 2601 byte(s)
Code sync towards a faster implementation. The key is to avoid virtual functions and inline as many functions as posible
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 "solution.h"
21
22 Solution::Solution(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 Solution::~Solution()
34 {
35 }
36
37 Solution::Solution(const Solution& input)
38 {
39 m_size = input.m_size;
40 for (int i=0; i<m_size; i++)
41 m_matrix[i] = input.m_matrix[i];
42 }
43
44 /*
45 void Solution::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 /*
52 inline bool Solution::getMatrix(int x, int y)
53 {
54 return (m_matrix[x] == y);
55 }*/
56 /*
57 void Solution::setMatrix(int x, int y, bool val)
58 {
59 if (val == true)
60 m_matrix[x] = y;
61 else
62 m_matrix[x] = -1;
63 }*/
64
65 bool Solution::operator ==(const Solution& s)
66 {
67 const Solution& sol = dynamic_cast<const Solution&>(s);
68 for (int i=0; i<m_size; i++)
69 if (m_matrix[i] != sol.m_matrix[i])
70 return false;
71 return true;
72 }
73
74 Solution* Solution::copy()
75 {
76 return new Solution(*this);
77 }
78
79 /*
80 void Solution::mirror()
81 {
82 unsigned char temp[MAX_SIZE];
83 for (int i=0; i<m_size; i++)
84 temp[i] = (m_size-1) - m_matrix[i];
85 set( temp );
86 }*/
87
88 /*
89 void Solution::rotate90()
90 {
91 unsigned char temp[MAX_SIZE];
92
93 for (int i=0; i<m_size; i++)
94 {
95 int x = i;
96 int y = m_matrix[i];
97
98 temp[y] = (m_size-1) - x;
99 }
100
101 set( temp);
102 }*/

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20