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

Annotation of /queensgui/src/solution.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 655 - (hide annotations) (download)
Fri Apr 23 05:57:28 2010 UTC (14 years, 1 month ago) by torben
File MIME type: text/plain
File size: 2640 byte(s)
Code sync towards a faster implementation. The key is to avoid virtual functions and inline as many functions as posible
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     bool operator ==(const Solution& sol);
50    
51     Solution* copy();
52    
53     //void mirror();
54     void mirror() {
55     unsigned char temp[MAX_SIZE];
56     for (int i=0; i<m_size; i++)
57     temp[i] = (m_size-1) - m_matrix[i];
58     set( temp );
59     }
60    
61     //void rotate90();
62     void rotate90() {
63     unsigned char temp[MAX_SIZE];
64     for (int i=0; i<m_size; i++) {
65     int x = i;
66     int y = m_matrix[i];
67     temp[y] = (m_size-1) - x;
68     }
69     set( temp);
70     }
71    
72    
73 torben 1 int size() {return m_size;};
74 torben 655 void setSize(int size) {m_size = size;};
75     private:
76     explicit Solution(const Solution& input);
77     //void set(unsigned char[MAX_SIZE]);
78     void set(unsigned char input[MAX_SIZE]) {
79     for (int i=0; i<m_size; i++)
80     m_matrix[i] = input[i];
81     }
82    
83    
84    
85     unsigned char m_matrix[MAX_SIZE];
86 torben 1 protected:
87     int m_size;
88 torben 655
89 torben 1 };
90    
91     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20