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

Diff of /queensgui/src/solution.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by torben, Thu Jul 19 22:26:42 2007 UTC revision 657 by torben, Fri Apr 23 07:36:31 2010 UTC
# Line 17  Line 17 
17   *   Free Software Foundation, Inc.,                                       *   *   Free Software Foundation, Inc.,                                       *
18   *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *   *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19   ***************************************************************************/   ***************************************************************************/
20  #ifndef SOLUTION_H  #ifndef SOLUTIONINT_H
21  #define SOLUTION_H  #define SOLUTIONINT_H
22    
23    //#include <solution.h>
24  #include "config.h"  #include "config.h"
25    
26  /**  class Solution
 @author Torben Nielsen  
 */  
 class Solution  
27  {  {
28  public:  public:
29        Solution(int size);
30    
31        ~Solution();
32    
33          // functions      //bool getMatrix(int x, int y);
34          Solution(int size=8);          bool getMatrix(int x, int y) {
35          Solution(const Solution &input);                  return (m_matrix[x] == y);
36          ~Solution();          }
37    
38          void set(bool input[MAX_SIZE][MAX_SIZE]);  
39          void rotate90();          //void setMatrix(int x, int y, bool val);
40          void mirror();          void setMatrix(int x, int y, bool val) {
41                    if (val == true)
42          Solution* copy();                  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] != s.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    
         bool operator==(const Solution& sol);  
         bool operator!=(const Solution& sol);  
80    
81          int size() {return m_size;};          int size() {return m_size;};
82          void setSize(int size) {m_size = size;};          void setSize(int size) {m_size = size;};
83            private:
84          bool matrix[MAX_SIZE][MAX_SIZE];          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:  protected:
95          int m_size;          int m_size;
96                    
97  };  };
98    
99  #endif  #endif

Legend:
Removed from v.2  
changed lines
  Added in v.657

  ViewVC Help
Powered by ViewVC 1.1.20