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

Line Exec Source
1
/*********************                                                        */
2
/*! \file tuple_project_op.cpp
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Mudathir Mohamed
6
 ** This file is part of the CVC4 project.
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.\endverbatim
11
 **
12
 ** \brief a class for TupleProjectOp operator
13
 **/
14
15
#include "tuple_project_op.h"
16
17
#include <iostream>
18
19
#include "expr/type_node.h"
20
21
namespace CVC4 {
22
23
6
std::ostream& operator<<(std::ostream& out, const TupleProjectOp& op)
24
{
25
24
  for (const uint32_t& index : op.getIndices())
26
  {
27
18
    out << " " << index;
28
  }
29
6
  return out;
30
}
31
32
100
size_t TupleProjectOpHashFunction::operator()(const TupleProjectOp& op) const
33
{
34
  // we expect most tuples to have length < 10.
35
  // Therefore we can implement a simple hash function
36
100
  size_t hash = 0;
37
340
  for (uint32_t index : op.getIndices())
38
  {
39
240
    hash = hash * 10 + index;
40
  }
41
100
  return hash;
42
}
43
44
20
TupleProjectOp::TupleProjectOp(std::vector<uint32_t> indices)
45
20
    : d_indices(std::move(indices))
46
{
47
20
}
48
49
134
const std::vector<uint32_t>& TupleProjectOp::getIndices() const { return d_indices; }
50
51
56
bool TupleProjectOp::operator==(const TupleProjectOp& op) const
52
{
53
56
  return d_indices == op.d_indices;
54
}
55
56
26685
}  // namespace CVC4