| 722 | |
| 723 | template <typename V> |
| 724 | std::optional<UuidTree<V>> UuidTree<V>::intersect(const std::vector<Uuid> &uuids) const { |
| 725 | // build new tree from selection |
| 726 | |
| 727 | std::list<UuidTree<V>> children; |
| 728 | |
| 729 | for (const auto &i : children_) { |
| 730 | auto ii = i.intersect(uuids); |
| 731 | if (ii) |
| 732 | children.emplace_back(*ii); |
| 733 | } |
| 734 | |
| 735 | if (not children.empty() or std::find(uuids.begin(), uuids.end(), uuid_) != uuids.end()) { |
| 736 | // preserve.. |
| 737 | auto result = UuidTree<V>(); |
| 738 | result.uuid_ = uuid_; |
| 739 | result.value_ = value_; |
| 740 | result.children_ = children; |
| 741 | return result; |
| 742 | } |
| 743 | |
| 744 | return {}; |
| 745 | } |
| 746 | |
| 747 | } // namespace xstudio::utility |