/[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 654 by torben, Fri Jul 20 16:58:04 2007 UTC revision 655 by torben, Fri Apr 23 05:57:28 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"
25    
26  /**  class Solution
 @author Torben Nielsen  
 */  
 class Solution  
27  {  {
28  public:  public:
29          virtual ~Solution() {}      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    
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    
         virtual void rotate90() = 0;  
         virtual void mirror() = 0;  
           
         virtual Solution* copy() = 0;  
   
         virtual bool operator==(const Solution& sol) = 0;  
         virtual bool getMatrix(int x, int y) = 0;  
         virtual void setMatrix(int x, int y, bool val) = 0;  
72    
73          int size() {return m_size;};          int size() {return m_size;};
74          void setSize(int size) {m_size = size;};          void setSize(int size) {m_size = size;};
75            private:
76          void print();          explicit Solution(const Solution& input);
77          void print(bool debug, int row, int col);          //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  protected:  protected:
87          int m_size;          int m_size;
88          Solution& operator=(Solution& s);                  
89  };  };
90    
91  #endif  #endif

Legend:
Removed from v.654  
changed lines
  Added in v.655

  ViewVC Help
Powered by ViewVC 1.1.20