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

Diff of /queensgui/src/solution.cpp

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

revision 2 by torben, Thu Jul 19 22:26:42 2007 UTC revision 656 by torben, Fri Apr 23 06:04:54 2010 UTC
# Line 19  Line 19 
19   ***************************************************************************/   ***************************************************************************/
20  #include "solution.h"  #include "solution.h"
21    
   
22  Solution::Solution(int size)  Solution::Solution(int size)
23  {  {
24          m_size = size;          m_size = size;
25          for (int i=0; i<m_size; i++)          
26                  for (int j=0; j<m_size; j++)          for (int i=0; i<size; i++)
27                          matrix[i][j] = false;          {
28                    m_matrix[i] = -1;
29            }
30  }  }
31    
32    
# Line 33  Solution::~Solution() Line 34  Solution::~Solution()
34  {  {
35  }  }
36    
37    Solution::Solution(const Solution& input)
 Solution::Solution(const Solution &input)  
38  {  {
39          m_size = input.m_size;          m_size = input.m_size;
40          for (int i=0; i<m_size; i++)          for (int i=0; i<m_size; i++)
41                  for (int j=0; j<m_size; j++)                  m_matrix[i] = input.m_matrix[i];
                         matrix[i][j] = input.matrix[i][j];  
42  }  }
43    
44    /*
45  void Solution::set(bool input[MAX_SIZE][MAX_SIZE])  void Solution::set(unsigned char input[MAX_SIZE])
46  {  {
47          for (int i=0; i<m_size; i++)          for (int i=0; i<m_size; i++)
48                  for (int j=0; j<m_size; j++)                  m_matrix[i] = input[i];
49                          matrix[i][j] = input[i][j];  }*/
 }  
   
50    
51  void Solution::rotate90()  /*
52    inline bool Solution::getMatrix(int x, int y)
53  {  {
54          bool temp[MAX_SIZE][MAX_SIZE];          return (m_matrix[x] == y);
55    }*/
56    /*
57    void Solution::setMatrix(int x, int y, bool val)
58    {
59            if (val == true)
60                    m_matrix[x] = y;
61            else
62                    m_matrix[x] = -1;
63    }*/
64    /*
65    bool Solution::operator ==(const Solution& s)
66    {
67            const Solution& sol = dynamic_cast<const Solution&>(s);
68          for (int i=0; i<m_size; i++)          for (int i=0; i<m_size; i++)
69                  for (int j=0; j<m_size; j++) {                  if (m_matrix[i] != sol.m_matrix[i])
70                          temp[j][(m_size-1)-i] = matrix[i][j];                          return false;
71                  }          return true;
72          set(temp);  }*/
 }  
73    
74  void Solution::mirror()  Solution* Solution::copy()
75  {  {
76          bool temp[MAX_SIZE][MAX_SIZE];          return new Solution(*this);
   
         for (int i=0; i<m_size; i++)  
                 for (int j=0; j<m_size;j++)  
                         temp[i][(m_size-1)-j] = matrix[i][j];  
         set(temp);  
77  }  }
78    
79    /*
80  bool Solution::operator==(const Solution& sol)  void Solution::mirror()
81  {  {
82            unsigned char temp[MAX_SIZE];
83          for (int i=0; i<m_size; i++)          for (int i=0; i<m_size; i++)
84                  for (int j=0; j<m_size; j++)                  temp[i] = (m_size-1) - m_matrix[i];
85                          if (matrix[i][j] != sol.matrix[i][j])          set( temp );
86                                  return false;  }*/
         return true;  
 }  
87    
88  bool Solution::operator!=(const Solution& sol)  /*
89    void Solution::rotate90()
90  {  {
91          int matchcount = 0;          unsigned char temp[MAX_SIZE];
92                    
93          for (int i=0; i<m_size; i++)          for (int i=0; i<m_size; i++)
94                  for (int j=0; j<m_size; j++)          {
95                          if (matrix[i][j] == sol.matrix[i][j])                  int x = i;
96                                  matchcount++;                  int y = m_matrix[i];
97          if (matchcount == (m_size*2) )  
98                  return false;                  temp[y] = (m_size-1) - x;
99          else          }
100                  return true;                  
101  }          set( temp);
102    }*/
103    
 Solution* Solution::copy()  
 {  
         return new Solution(*this);  
 }  

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

  ViewVC Help
Powered by ViewVC 1.1.20