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 : 482 : bool VariadicTrie::add(Node n, const std::vector<Node>& i) 18 : : { 19 : 482 : VariadicTrie* curr = this; 20 [ + + ]: 1029 : for (const Node& ic : i) 21 : : { 22 : 547 : curr = &(curr->d_children[ic]); 23 : : } 24 [ + - ]: 482 : if (curr->d_data.isNull()) 25 : : { 26 : 482 : curr->d_data = n; 27 : 482 : return true; 28 : : } 29 : 0 : return false; 30 : : } 31 : : 32 : 4220 : bool VariadicTrie::hasSubset(const std::vector<Node>& is) const 33 : : { 34 [ + + ]: 4220 : if (!d_data.isNull()) 35 : : { 36 : 710 : return true; 37 : : } 38 [ + + ]: 29976 : for (const std::pair<const Node, VariadicTrie>& p : d_children) 39 : : { 40 : 27352 : Node n = p.first; 41 [ + + ]: 27352 : if (std::find(is.begin(), is.end(), n) != is.end()) 42 : : { 43 [ + + ]: 1008 : if (p.second.hasSubset(is)) 44 : : { 45 : 886 : return true; 46 : : } 47 : : } 48 [ + + ]: 27352 : } 49 : 2624 : return false; 50 : : } 51 : : 52 : : } // namespace cvc5::internal