Append the entries of select to list in a topologically valid order. * * Complexity: O(select.Count() * log(select.Count())). */
| 314 | * Complexity: O(select.Count() * log(select.Count())). |
| 315 | */ |
| 316 | void AppendTopo(std::vector<DepGraphIndex>& list, const SetType& select) const noexcept |
| 317 | { |
| 318 | DepGraphIndex old_len = list.size(); |
| 319 | for (auto i : select) list.push_back(i); |
| 320 | std::ranges::sort(std::span{list}.subspan(old_len), [&](DepGraphIndex a, DepGraphIndex b) noexcept { |
| 321 | const auto a_anc_count = entries[a].ancestors.Count(); |
| 322 | const auto b_anc_count = entries[b].ancestors.Count(); |
| 323 | if (a_anc_count != b_anc_count) return a_anc_count < b_anc_count; |
| 324 | return a < b; |
| 325 | }); |
| 326 | } |
| 327 | |
| 328 | /** Check if this graph is acyclic. */ |
| 329 | bool IsAcyclic() const noexcept |