| 298 | |
| 299 | template <typename T> |
| 300 | bool compare_collection(const collection_base<T>& a, const collection_base<T>& b) { |
| 301 | if (a.children.size() == b.children.size()) { |
| 302 | auto at = a.children.begin(); |
| 303 | auto bt = b.children.begin(); |
| 304 | for (; at != a.children.end(); ++at, ++bt) { |
| 305 | const bool a_lt_b = less(*at, *bt); |
| 306 | const bool b_lt_a = less(*bt, *at); |
| 307 | if (!a_lt_b && !b_lt_a) { |
| 308 | // Elements equal. |
| 309 | continue; |
| 310 | } |
| 311 | return a_lt_b; |
| 312 | } |
| 313 | // Vectors equal, compare matrix (in case of mapped items). |
| 314 | return compare(*a.matrix, *b.matrix); |
| 315 | } |
| 316 | else { |
| 317 | return a.children.size() < b.children.size(); |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | bool compare(const loop& a, const loop& b) { |
| 322 | return compare_collection<edge>(a, b); |