1 #include <bf/counter_vector.h>
8 : bits_(cells * width), width_(width)
16 assert(cell <
size());
18 size_t lsb = cell * width_;
22 for (
size_t i = 0; i < width_; ++i)
25 bits_[lsb + i] =
true;
32 for (
size_t i = 0; i < width_; ++i)
34 bool b1 = bits_[lsb + i];
35 bool b2 = value & (1 << i);
36 bits_[lsb + i] ^= b2 != carry;
37 carry = carry ? b1 || b2 : b1 && b2;
41 for (
size_t i = 0; i < width_; ++i)
42 bits_[lsb + i] =
true;
49 assert(cell <
size());
50 size_t lsb = cell * width_;
51 for (
auto i = lsb; i < lsb + width_; ++i)
64 assert(cell <
size());
65 size_t cnt = 0, order = 1;
66 size_t lsb = cell * width_;
67 for (
auto i = lsb; i < lsb + width_; ++i, order <<= 1)
75 assert(cell <
size());
76 assert(value <=
max());
78 auto lsb = cell * width_;
79 for (
size_t i = 0; i < width_; ++i)
80 bits_[lsb + i] = bits[i];
90 return bits_.
size() / width_;
95 using limits = std::numeric_limits<size_t>;
96 return limits::max() >> (limits::digits -
width());
106 return to_string(v.bits_,
false, all, cut_off);