| 758 | |
| 759 | /** Compare two miniscript subtrees, using a non-recursive algorithm. */ |
| 760 | friend int Compare(const Node<Key>& node1, const Node<Key>& node2) |
| 761 | { |
| 762 | std::vector<std::pair<const Node<Key>&, const Node<Key>&>> queue; |
| 763 | queue.emplace_back(node1, node2); |
| 764 | while (!queue.empty()) { |
| 765 | const auto& [a, b] = queue.back(); |
| 766 | queue.pop_back(); |
| 767 | if (std::tie(a.fragment, a.k, a.keys, a.data) < std::tie(b.fragment, b.k, b.keys, b.data)) return -1; |
| 768 | if (std::tie(b.fragment, b.k, b.keys, b.data) < std::tie(a.fragment, a.k, a.keys, a.data)) return 1; |
| 769 | if (a.subs.size() < b.subs.size()) return -1; |
| 770 | if (b.subs.size() < a.subs.size()) return 1; |
| 771 | size_t n = a.subs.size(); |
| 772 | for (size_t i = 0; i < n; ++i) { |
| 773 | queue.emplace_back(a.subs[n - 1 - i], b.subs[n - 1 - i]); |
| 774 | } |
| 775 | } |
| 776 | return 0; |
| 777 | } |
| 778 | |
| 779 | //! Compute the type for this miniscript. |
| 780 | Type CalcType() const { |
nothing calls this directly
no test coverage detected