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

Contents of /queensgui/src/solution.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 656 - (show annotations) (download)
Fri Apr 23 06:04:54 2010 UTC (14 years ago) by torben
File MIME type: text/plain
File size: 2870 byte(s)
inline one more function
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 #ifndef SOLUTIONINT_H
21 #define SOLUTIONINT_H
22
23 //#include <solution.h>
24 #include "config.h"
25
26 class Solution
27 {
28 public:
29 Solution(int size);
30
31 ~Solution();
32
33 //bool getMatrix(int x, int y);
34 bool getMatrix(int x, int y) {
35 return (m_matrix[x] == y);
36 }
37
38
39 //void setMatrix(int x, int y, bool val);
40 void setMatrix(int x, int y, bool val) {
41 if (val == true)
42 m_matrix[x] = y;
43 else
44 m_matrix[x] = -1;
45 }
46
47
48
49 //bool operator ==(const Solution& sol);
50 bool operator ==(const Solution& s)
51 {
52 const Solution& sol = dynamic_cast<const Solution&>(s);
53 for (int i=0; i<m_size; i++)
54 if (m_matrix[i] != sol.m_matrix[i])
55 return false;
56 return true;
57 }
58
59 Solution* copy();
60
61 //void mirror();
62 void mirror() {
63 unsigned char temp[MAX_SIZE];
64 for (int i=0; i<m_size; i++)
65 temp[i] = (m_size-1) - m_matrix[i];
66 set( temp );
67 }
68
69 //void rotate90();
70 void rotate90() {
71 unsigned char temp[MAX_SIZE];
72 for (int i=0; i<m_size; i++) {
73 int x = i;
74 int y = m_matrix[i];
75 temp[y] = (m_size-1) - x;
76 }
77 set( temp);
78 }
79
80
81 int size() {return m_size;};
82 void setSize(int size) {m_size = size;};
83 private:
84 explicit Solution(const Solution& input);
85 //void set(unsigned char[MAX_SIZE]);
86 void set(unsigned char input[MAX_SIZE]) {
87 for (int i=0; i<m_size; i++)
88 m_matrix[i] = input[i];
89 }
90
91
92
93 unsigned char m_matrix[MAX_SIZE];
94 protected:
95 int m_size;
96
97 };
98
99 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20