131 |
131 |
132 for (QVector<Solution>::iterator solp = m_solutions.begin(); solp != m_solutions.end(); ++solp) |
132 for (QVector<Solution>::iterator solp = m_solutions.begin(); solp != m_solutions.end(); ++solp) |
133 { |
133 { |
134 const Solution& sol = *solp; |
134 const Solution& sol = *solp; |
135 |
135 |
136 if (m_bestSolution == null || sol > *m_bestSolution) |
136 if (m_bestSolution == null || sol.isBetterThan (m_bestSolution)) |
137 m_bestSolution = / |
137 m_bestSolution = / |
138 } |
138 } |
139 |
139 |
140 return (m_bestSolution != null); |
140 return (m_bestSolution != null); |
141 } |
141 } |
142 |
142 |
143 // ============================================================================= |
143 // ============================================================================= |
144 // ----------------------------------------------------------------------------- |
144 // ----------------------------------------------------------------------------- |
145 bool RingFinder::Solution::operator> (const RingFinder::Solution& other) const |
145 bool RingFinder::Solution::isBetterThan (const Solution* other) const |
146 { |
146 { |
147 // If this solution has less components than the other one, this one |
147 // If this solution has less components than the other one, this one |
148 // is definitely better. |
148 // is definitely better. |
149 if (getComponents().size() < other.getComponents().size()) |
149 if (getComponents().size() < other->getComponents().size()) |
150 return true; |
150 return true; |
151 |
151 |
152 // vice versa |
152 // vice versa |
153 if (other.getComponents().size() < getComponents().size()) |
153 if (other->getComponents().size() < getComponents().size()) |
154 return false; |
154 return false; |
155 |
155 |
156 // Calculate the maximum ring number. Since the solutions have equal |
156 // Calculate the maximum ring number. Since the solutions have equal |
157 // ring counts, the solutions with lesser maximum rings should result |
157 // ring counts, the solutions with lesser maximum rings should result |
158 // in cleaner code and less new primitives, right? |
158 // in cleaner code and less new primitives, right? |