MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / AppendTopo

Method AppendTopo

src/cluster_linearize.h:316–326  ·  view source on GitHub ↗

Append the entries of select to list in a topologically valid order. * * Complexity: O(select.Count() * log(select.Count())). */

Source from the content-addressed store, hash-verified

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

Callers 1

SimpleLinearizeFunction · 0.80

Calls 3

sizeMethod · 0.45
push_backMethod · 0.45
CountMethod · 0.45

Tested by 1

SimpleLinearizeFunction · 0.64