Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * Variadic trie utility 11 : : */ 12 : : 13 : : #include "expr/variadic_trie.h" 14 : : 15 : : namespace cvc5::internal { 16 : : 17 : 514 : bool VariadicTrie::add(Node n, const std::vector<Node>& i) 18 : : { 19 : 514 : VariadicTrie* curr = this; 20 [ + + ]: 1113 : for (const Node& ic : i) 21 : : { 22 : 599 : curr = &(curr->d_children[ic]); 23 : : } 24 [ + - ]: 514 : if (curr->d_data.isNull()) 25 : : { 26 : 514 : curr->d_data = n; 27 : 514 : return true; 28 : : } 29 : 0 : return false; 30 : : } 31 : : 32 : 6493 : bool VariadicTrie::hasSubset(const std::vector<Node>& is) const 33 : : { 34 [ + + ]: 6493 : if (!d_data.isNull()) 35 : : { 36 : 1607 : return true; 37 : : } 38 [ + + ]: 46734 : for (const std::pair<const Node, VariadicTrie>& p : d_children) 39 : : { 40 : 43788 : Node n = p.first; 41 [ + + ]: 43788 : if (std::find(is.begin(), is.end(), n) != is.end()) 42 : : { 43 [ + + ]: 2622 : if (p.second.hasSubset(is)) 44 : : { 45 : 1940 : return true; 46 : : } 47 : : } 48 [ + + ]: 43788 : } 49 : 2946 : return false; 50 : : } 51 : : 52 : : } // namespace cvc5::internal