summaryrefslogtreecommitdiff
path: root/src/expr/kind_map.h
blob: 3c5f27c4971712691837aba9e3248af27a3b86d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/******************************************************************************
 * Top contributors (to current version):
 *   Gereon Kremer, Mathias Preiner, Dejan Jovanovic
 *
 * This file is part of the cvc5 project.
 *
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
 * in the top-level source directory and their institutional affiliations.
 * All rights reserved.  See the file COPYING in the top-level source
 * directory for licensing information.
 * ****************************************************************************
 *
 * A bitmap of Kinds.
 *
 * This is a class representation for a bitmap of Kinds that is iterable,
 * manipulable, and packed.
 */

#include "cvc5_private.h"

#ifndef CVC5__KIND_MAP_H
#define CVC5__KIND_MAP_H

#include <bitset>

#include "base/check.h"
#include "expr/kind.h"

namespace cvc5 {

/** A very simple bitmap for Kinds */
class KindMap
{
 public:
  /** Set the bit for k */
  void set(Kind k) { d_bits.set(fromKind(k)); }
  /** Reset the bit for k */
  void reset(Kind k) { d_bits.reset(fromKind(k)); }
  /** Check whether the bit for k is set */
  bool test(Kind k) const { return d_bits.test(fromKind(k)); }
  /** Check whether the bit for k is set */
  bool operator[](Kind k) const { return test(k); }

 private:
  /** Convert kind to std::size_t and check bounds */
  static std::size_t fromKind(Kind k)
  {
    AssertArgument(k >= Kind(0) && k < kind::LAST_KIND, k, "invalid kind");
    return static_cast<std::size_t>(k);
  }
  /** The bitmap */
  std::bitset<kind::LAST_KIND> d_bits;
};

}  // namespace cvc5

#endif /* CVC5__KIND_MAP_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback