10 #ifndef INCLUDE_MOLASSEMBLER_TEMPLE_BITSET_H
11 #define INCLUDE_MOLASSEMBLER_TEMPLE_BITSET_H
17 namespace Molassembler {
25 template<std::
size_t N>
44 for(
auto& block : storage) {
53 constexpr
void set(
const std::size_t i) {
54 std::size_t blockIndex = Math::floor(static_cast<double>(i) /
bitsPerBlock);
57 storage.at(blockIndex) |= (1ULL << bitIndex);
64 constexpr
void unset(
const std::size_t i) {
65 std::size_t blockIndex = Math::floor(static_cast<double>(i) /
bitsPerBlock);
68 storage.at(blockIndex) ^= (1ULL << bitIndex);
75 constexpr
void set(
const std::size_t i,
const bool value) {
90 constexpr
bool test(
const std::size_t i)
const {
91 std::size_t blockIndex = Math::floor(static_cast<double>(i) /
bitsPerBlock);
95 storage.at(blockIndex) & (1ULL << bitIndex)
103 using Block =
long long unsigned;
111 static_cast<double>(std::numeric_limits<Block>::max()),
117 static constexpr std::size_t
B = Math::ceil(
118 static_cast<double>(N) / static_cast<double>(
bitsPerBlock)
constexpr Bitset()
Zeroing constructor.
Definition: Bitset.h:34
constexpr void set(const std::size_t i, const bool value)
Sets a specific bit to a specified value.
Definition: Bitset.h:75
constexpr math implementations
constexpr void unset(const std::size_t i)
Unsets a specific bit.
Definition: Bitset.h:64
constexpr void set(const std::size_t i)
Sets a specific bit.
Definition: Bitset.h:53
static constexpr std::size_t bitsPerBlock
Number of bits per block.
Definition: Bitset.h:109
Constexpr bitset class.
Definition: Bitset.h:26
static constexpr std::size_t B
Number of Block types stored.
Definition: Bitset.h:117
constexpr bool test(const std::size_t i) const
Test the value at a particular bit.
Definition: Bitset.h:90
constexpr void zero()
Zero out all bits.
Definition: Bitset.h:43