1#ifndef PER_STATE_BITSET_H
2#define PER_STATE_BITSET_H
4#include "downward/per_state_array.h"
10 using Block =
unsigned int;
12 !std::numeric_limits<Block>::is_signed,
13 "Block type must be unsigned");
15 static const Block zeros = Block(0);
17 static const Block ones = Block(~Block(0));
18 static const int bits_per_block = std::numeric_limits<Block>::digits;
20 static int compute_num_blocks(std::size_t num_bits);
21 static std::size_t block_index(std::size_t pos);
22 static std::size_t bit_index(std::size_t pos);
23 static Block bit_mask(std::size_t pos);
26class ConstBitsetView {
27 ConstArrayView<BitsetMath::Block> data;
31 ConstBitsetView(ConstArrayView<BitsetMath::Block> data,
int num_bits)
37 ConstBitsetView(
const ConstBitsetView& other) =
default;
38 ConstBitsetView& operator=(
const ConstBitsetView& other) =
default;
40 bool test(
int index)
const;
45 ArrayView<BitsetMath::Block> data;
49 BitsetView(ArrayView<BitsetMath::Block> data,
int num_bits)
55 BitsetView(
const BitsetView& other) =
default;
56 BitsetView& operator=(
const BitsetView& other) =
default;
58 operator ConstBitsetView()
const {
return ConstBitsetView(data, num_bits); }
61 void reset(
int index);
63 bool test(
int index)
const;
64 void intersect(
const BitsetView& other);
69 int num_bits_per_entry;
70 PerStateArray<BitsetMath::Block> data;
73 explicit PerStateBitset(
const std::vector<bool>& default_bits);
75 PerStateBitset(
const PerStateBitset&) =
delete;
76 PerStateBitset& operator=(
const PerStateBitset&) =
delete;
78 BitsetView operator[](
const State& state);
79 ConstBitsetView operator[](
const State& state)
const;