Modify this transaction graph, adding multiple parents to a specified child. * * Complexity: O(N) where N=TxCount(). */
| 178 | * Complexity: O(N) where N=TxCount(). |
| 179 | */ |
| 180 | void AddDependencies(const SetType& parents, DepGraphIndex child) noexcept |
| 181 | { |
| 182 | Assume(m_used[child]); |
| 183 | Assume(parents.IsSubsetOf(m_used)); |
| 184 | // Compute the ancestors of parents that are not already ancestors of child. |
| 185 | SetType par_anc; |
| 186 | for (auto par : parents - Ancestors(child)) { |
| 187 | par_anc |= Ancestors(par); |
| 188 | } |
| 189 | par_anc -= Ancestors(child); |
| 190 | // Bail out if there are no such ancestors. |
| 191 | if (par_anc.None()) return; |
| 192 | // To each such ancestor, add as descendants the descendants of the child. |
| 193 | const auto& chl_des = entries[child].descendants; |
| 194 | for (auto anc_of_par : par_anc) { |
| 195 | entries[anc_of_par].descendants |= chl_des; |
| 196 | } |
| 197 | // To each descendant of the child, add those ancestors. |
| 198 | for (auto dec_of_chl : Descendants(child)) { |
| 199 | entries[dec_of_chl].ancestors |= par_anc; |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | /** Compute the (reduced) set of parents of node i in this graph. |
| 204 | * |
nothing calls this directly
no test coverage detected