/[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 3 by torben, Thu Jul 19 22:26:42 2007 UTC revision 4 by torben, Thu Jul 19 23:44:01 2007 UTC
# Line 25  Solution::Solution(int size) Line 25  Solution::Solution(int size)
25          m_size = size;          m_size = size;
26          for (int i=0; i<m_size; i++)          for (int i=0; i<m_size; i++)
27                  for (int j=0; j<m_size; j++)                  for (int j=0; j<m_size; j++)
28                          matrix[i][j] = false;                          m_matrix[i][j] = false;
29  }  }
30    
31    
# Line 39  Solution::Solution(const Solution &input Line 39  Solution::Solution(const Solution &input
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++)                  for (int j=0; j<m_size; j++)
42                          matrix[i][j] = input.matrix[i][j];                          m_matrix[i][j] = input.m_matrix[i][j];
43  }  }
44    
45    
# Line 47  void Solution::set(bool input[MAX_SIZE][ Line 47  void Solution::set(bool input[MAX_SIZE][
47  {  {
48          for (int i=0; i<m_size; i++)          for (int i=0; i<m_size; i++)
49                  for (int j=0; j<m_size; j++)                  for (int j=0; j<m_size; j++)
50                          matrix[i][j] = input[i][j];                          m_matrix[i][j] = input[i][j];
51  }  }
52    
53    
# Line 57  void Solution::rotate90() Line 57  void Solution::rotate90()
57    
58          for (int i=0; i<m_size; i++)          for (int i=0; i<m_size; i++)
59                  for (int j=0; j<m_size; j++) {                  for (int j=0; j<m_size; j++) {
60                          temp[j][(m_size-1)-i] = matrix[i][j];                          temp[j][(m_size-1)-i] = m_matrix[i][j];
61                  }                  }
62          set(temp);          set(temp);
63  }  }
# Line 68  void Solution::mirror() Line 68  void Solution::mirror()
68    
69          for (int i=0; i<m_size; i++)          for (int i=0; i<m_size; i++)
70                  for (int j=0; j<m_size;j++)                  for (int j=0; j<m_size;j++)
71                          temp[i][(m_size-1)-j] = matrix[i][j];                          temp[i][(m_size-1)-j] = m_matrix[i][j];
72          set(temp);          set(temp);
73  }  }
74    
# Line 77  bool Solution::operator==(const Solution Line 77  bool Solution::operator==(const Solution
77  {  {
78          for (int i=0; i<m_size; i++)          for (int i=0; i<m_size; i++)
79                  for (int j=0; j<m_size; j++)                  for (int j=0; j<m_size; j++)
80                          if (matrix[i][j] != sol.matrix[i][j])                          if (m_matrix[i][j] != sol.m_matrix[i][j])
81                                  return false;                                  return false;
82          return true;          return true;
83  }  }
# Line 87  bool Solution::operator!=(const Solution Line 87  bool Solution::operator!=(const Solution
87          int matchcount = 0;          int matchcount = 0;
88          for (int i=0; i<m_size; i++)          for (int i=0; i<m_size; i++)
89                  for (int j=0; j<m_size; j++)                  for (int j=0; j<m_size; j++)
90                          if (matrix[i][j] == sol.matrix[i][j])                          if (m_matrix[i][j] == sol.m_matrix[i][j])
91                                  matchcount++;                                  matchcount++;
92          if (matchcount == (m_size*2) )          if (matchcount == (m_size*2) )
93                  return false;                  return false;
# Line 95  bool Solution::operator!=(const Solution Line 95  bool Solution::operator!=(const Solution
95                  return true;                  return true;
96  }  }
97    
98    bool Solution::getMatrix(int x, int y) {
99            return m_matrix[x][y];
100    }
101    
102    void Solution::setMatrix(int x, int y, bool val) {
103            m_matrix[x][y] = val;
104    }
105    
106    
107  Solution* Solution::copy()  Solution* Solution::copy()
108  {  {
109          return new Solution(*this);          return new Solution(*this);

Legend:
Removed from v.3  
changed lines
  Added in v.4

  ViewVC Help
Powered by ViewVC 1.1.20