131 // ----------------------------------------------------------------------------- |
131 // ----------------------------------------------------------------------------- |
132 bool numeric (const str& tok) |
132 bool numeric (const str& tok) |
133 { bool gotDot = false; |
133 { bool gotDot = false; |
134 |
134 |
135 for (int i = 0; i < tok.length(); ++i) |
135 for (int i = 0; i < tok.length(); ++i) |
136 { const qchar c = tok[i]; |
136 { const QChar c = tok[i]; |
137 |
137 |
138 // Allow leading hyphen for negatives |
138 // Allow leading hyphen for negatives |
139 if (i == 0 && c == '-') |
139 if (i == 0 && c == '-') |
140 continue; |
140 continue; |
141 |
141 |
374 // ============================================================================= |
374 // ============================================================================= |
375 // ----------------------------------------------------------------------------- |
375 // ----------------------------------------------------------------------------- |
376 bool RingFinder::Solution::operator> (const RingFinder::Solution& other) const |
376 bool RingFinder::Solution::operator> (const RingFinder::Solution& other) const |
377 { // If this solution has less components than the other one, this one |
377 { // If this solution has less components than the other one, this one |
378 // is definitely better. |
378 // is definitely better. |
379 if (components().size() < other.components().size()) |
379 if (getComponents().size() < other.getComponents().size()) |
380 return true; |
380 return true; |
381 |
381 |
382 // vice versa |
382 // vice versa |
383 if (other.components().size() < components().size()) |
383 if (other.getComponents().size() < getComponents().size()) |
384 return false; |
384 return false; |
385 |
385 |
386 // Calculate the maximum ring number. Since the solutions have equal |
386 // Calculate the maximum ring number. Since the solutions have equal |
387 // ring counts, the solutions with lesser maximum rings should result |
387 // ring counts, the solutions with lesser maximum rings should result |
388 // in cleaner code and less new primitives, right? |
388 // in cleaner code and less new primitives, right? |
389 int maxA = 0, |
389 int maxA = 0, |
390 maxB = 0; |
390 maxB = 0; |
391 |
391 |
392 for (int i = 0; i < components().size(); ++i) |
392 for (int i = 0; i < getComponents().size(); ++i) |
393 { if (components()[i].num > maxA) |
393 { if (getComponents()[i].num > maxA) |
394 maxA = components()[i].num; |
394 maxA = getComponents()[i].num; |
395 |
395 |
396 if (other.components()[i].num > maxB) |
396 if (other.getComponents()[i].num > maxB) |
397 maxB = other.components()[i].num; |
397 maxB = other.getComponents()[i].num; |
398 } |
398 } |
399 |
399 |
400 if (maxA < maxB) |
400 if (maxA < maxB) |
401 return true; |
401 return true; |
402 |
402 |