| 273 | } |
| 274 | |
| 275 | void AddChildrenTo(HierarchyLinker::Node::Ptrs & trees, |
| 276 | std::function<std::vector<HierarchyPlace>(CompositeId const &)> const & fn) |
| 277 | { |
| 278 | for (auto & tree : trees) |
| 279 | { |
| 280 | CHECK(!tree->HasParent(), ()); |
| 281 | |
| 282 | tree_node::PostOrderVisit(tree, [&](auto const & n) |
| 283 | { |
| 284 | auto const id = n->GetData().GetCompositeId(); |
| 285 | auto const & places = fn(id); |
| 286 | for (auto place : places) |
| 287 | { |
| 288 | auto const newNode = tree_node::MakeTreeNode(std::move(place)); |
| 289 | tree_node::Link(newNode, n); |
| 290 | } |
| 291 | }); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | void FlattenBuildingParts(HierarchyLinker::Node::Ptrs & trees) |
| 296 | { |