1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Aina Niemetz |
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 |
|
* Implementation of type node identifier trie. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "theory/quantifiers/sygus/type_node_id_trie.h" |
17 |
|
|
18 |
|
using namespace cvc5::kind; |
19 |
|
|
20 |
|
namespace cvc5 { |
21 |
|
namespace theory { |
22 |
|
namespace quantifiers { |
23 |
|
|
24 |
878 |
void TypeNodeIdTrie::add(Node v, std::vector<TypeNode>& types) |
25 |
|
{ |
26 |
878 |
TypeNodeIdTrie* tnt = this; |
27 |
2486 |
for (unsigned i = 0, size = types.size(); i < size; i++) |
28 |
|
{ |
29 |
1608 |
tnt = &tnt->d_children[types[i]]; |
30 |
|
} |
31 |
878 |
tnt->d_data.push_back(v); |
32 |
878 |
} |
33 |
|
|
34 |
1373 |
void TypeNodeIdTrie::assignIds(std::map<Node, unsigned>& assign, |
35 |
|
unsigned& idCount) |
36 |
|
{ |
37 |
1373 |
if (!d_data.empty()) |
38 |
|
{ |
39 |
1392 |
for (const Node& v : d_data) |
40 |
|
{ |
41 |
878 |
assign[v] = idCount; |
42 |
|
} |
43 |
514 |
idCount++; |
44 |
|
} |
45 |
2219 |
for (std::pair<const TypeNode, TypeNodeIdTrie>& c : d_children) |
46 |
|
{ |
47 |
846 |
c.second.assignIds(assign, idCount); |
48 |
|
} |
49 |
1373 |
} |
50 |
|
|
51 |
|
} // namespace quantifiers |
52 |
|
} // namespace theory |
53 |
29598 |
} // namespace cvc5 |