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

Annotation of /queensgui/src/solution.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 657 - (hide annotations) (download)
Fri Apr 23 07:36:31 2010 UTC (14 years, 1 month ago) by torben
File MIME type: text/plain
File size: 2870 byte(s)
no need for this dynamic_cast<>
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 655 #ifndef SOLUTIONINT_H
21     #define SOLUTIONINT_H
22 torben 1
23 torben 655 //#include <solution.h>
24     #include "config.h"
25 torben 1
26 torben 655 class Solution
27 torben 1 {
28     public:
29 torben 655 Solution(int size);
30 torben 1
31 torben 655 ~Solution();
32 torben 1
33 torben 655 //bool getMatrix(int x, int y);
34     bool getMatrix(int x, int y) {
35     return (m_matrix[x] == y);
36     }
37 torben 1
38 torben 655
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 torben 656 //bool operator ==(const Solution& sol);
50     bool operator ==(const Solution& s)
51     {
52 torben 657 //const Solution& sol = dynamic_cast<const Solution&>(s);
53 torben 656 for (int i=0; i<m_size; i++)
54 torben 657 if (m_matrix[i] != s.m_matrix[i])
55 torben 656 return false;
56     return true;
57     }
58 torben 655
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 torben 1 int size() {return m_size;};
82 torben 655 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 torben 1 protected:
95     int m_size;
96 torben 655
97 torben 1 };
98    
99     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20