GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/expr/variadic_trie.cpp Lines: 18 18 100.0 %
Date: 2021-11-07 Branches: 19 26 73.1 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * Variadic trie utility
14
 */
15
16
#include "expr/variadic_trie.h"
17
18
namespace cvc5 {
19
20
2400
bool VariadicTrie::add(Node n, const std::vector<Node>& i)
21
{
22
2400
  VariadicTrie* curr = this;
23
4802
  for (const Node& ic : i)
24
  {
25
2402
    curr = &(curr->d_children[ic]);
26
  }
27
2400
  if (curr->d_data.isNull())
28
  {
29
2312
    curr->d_data = n;
30
2312
    return true;
31
  }
32
88
  return false;
33
}
34
35
4350
bool VariadicTrie::hasSubset(const std::vector<Node>& is) const
36
{
37
4350
  if (!d_data.isNull())
38
  {
39
164
    return true;
40
  }
41
2296164
  for (const std::pair<const Node, VariadicTrie>& p : d_children)
42
  {
43
4584120
    Node n = p.first;
44
2292142
    if (std::find(is.begin(), is.end(), n) != is.end())
45
    {
46
164
      if (p.second.hasSubset(is))
47
      {
48
164
        return true;
49
      }
50
    }
51
  }
52
4022
  return false;
53
}
54
55
31137
}  // namespace cvc5