Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * A bitmap of Kinds. 11 : : * 12 : : * This is a class representation for a bitmap of Kinds that is iterable, 13 : : * manipulable, and packed. 14 : : */ 15 : : 16 : : #include "cvc5_private.h" 17 : : 18 : : #ifndef CVC5__KIND_MAP_H 19 : : #define CVC5__KIND_MAP_H 20 : : 21 : : #include <bitset> 22 : : 23 : : #include "base/check.h" 24 : : #include "expr/kind.h" 25 : : 26 : : namespace cvc5::internal { 27 : : 28 : : /** A very simple bitmap for Kinds */ 29 : : class KindMap 30 : : { 31 : : public: 32 : : /** Set the bit for k */ 33 : 6938003 : void set(Kind k) { d_bits.set(fromKind(k)); } 34 : : /** Reset the bit for k */ 35 : 1 : void reset(Kind k) { d_bits.reset(fromKind(k)); } 36 : : /** Check whether the bit for k is set */ 37 : 11889760 : bool test(Kind k) const { return d_bits.test(fromKind(k)); } 38 : : /** Check whether the bit for k is set */ 39 : 8805575 : bool operator[](Kind k) const { return test(k); } 40 : : 41 : : private: 42 : : /** Convert kind to std::size_t and check bounds */ 43 : 18827764 : static std::size_t fromKind(Kind k) 44 : : { 45 [ + - ][ + + ]: 18827764 : AssertArgument(k >= Kind(0) && k < Kind::LAST_KIND, k, "invalid kind"); [ + + ] 46 : 18827763 : return static_cast<std::size_t>(k); 47 : : } 48 : : /** The bitmap */ 49 : : std::bitset<static_cast<size_t>(Kind::LAST_KIND)> d_bits; 50 : : }; 51 : : 52 : : } // namespace cvc5::internal 53 : : 54 : : #endif /* CVC5__KIND_MAP_H */