GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/datatypes/tuple_project_op.cpp Lines: 16 16 100.0 %
Date: 2021-05-22 Branches: 10 16 62.5 %

Line Exec Source
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
100
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
100
  size_t hash = 0;
38
340
  for (uint32_t index : op.getIndices())
39
  {
40
240
    hash = hash * 10 + index;
41
  }
42
100
  return hash;
43
}
44
45
20
TupleProjectOp::TupleProjectOp(std::vector<uint32_t> indices)
46
20
    : d_indices(std::move(indices))
47
{
48
20
}
49
50
138
const std::vector<uint32_t>& TupleProjectOp::getIndices() const { return d_indices; }
51
52
56
bool TupleProjectOp::operator==(const TupleProjectOp& op) const
53
{
54
56
  return d_indices == op.d_indices;
55
}
56
57
28191
}  // namespace cvc5