1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Mudathir Mohamed |
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 |
|
* A class for TupleProjectOp operator. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "tuple_project_op.h" |
17 |
|
|
18 |
|
#include <iostream> |
19 |
|
|
20 |
|
#include "expr/type_node.h" |
21 |
|
|
22 |
|
namespace cvc5 { |
23 |
|
|
24 |
6 |
std::ostream& operator<<(std::ostream& out, const TupleProjectOp& op) |
25 |
|
{ |
26 |
24 |
for (const uint32_t& index : op.getIndices()) |
27 |
|
{ |
28 |
18 |
out << " " << index; |
29 |
|
} |
30 |
6 |
return out; |
31 |
|
} |
32 |
|
|
33 |
110 |
size_t TupleProjectOpHashFunction::operator()(const TupleProjectOp& op) const |
34 |
|
{ |
35 |
|
// we expect most tuples to have length < 10. |
36 |
|
// Therefore we can implement a simple hash function |
37 |
110 |
size_t hash = 0; |
38 |
410 |
for (uint32_t index : op.getIndices()) |
39 |
|
{ |
40 |
300 |
hash = hash * 10 + index; |
41 |
|
} |
42 |
110 |
return hash; |
43 |
|
} |
44 |
|
|
45 |
22 |
TupleProjectOp::TupleProjectOp(std::vector<uint32_t> indices) |
46 |
22 |
: d_indices(std::move(indices)) |
47 |
|
{ |
48 |
22 |
} |
49 |
|
|
50 |
200 |
const std::vector<uint32_t>& TupleProjectOp::getIndices() const { return d_indices; } |
51 |
|
|
52 |
60 |
bool TupleProjectOp::operator==(const TupleProjectOp& op) const |
53 |
|
{ |
54 |
60 |
return d_indices == op.d_indices; |
55 |
|
} |
56 |
|
|
57 |
29505 |
} // namespace cvc5 |