11 #ifndef __BITSET_HEADER
12 #define __BITSET_HEADER
15 #include "../util/byte_operation.hpp"
18 template<u
int16_t Nbit>
20 typedef uint16_t size_type;
25 reference(uint8_t & unit, uint8_t
const & subpos): unit_(unit), subpos_(subpos) {
28 operator bool()
const {
35 reference&
operator=(
const reference& state) {
49 uint8_t
const subpos_;
58 for(size_type
i = 0;
i < (Nbit + 7) / 8; ++
i) {
59 array_[
i] = arg.array_[
i];
63 for(size_type
i = 0;
i < (Nbit + 7) / 8; ++
i) {
64 array_[
i] = rhs.array_[
i];
70 for(size_type
i = 0;
i < (Nbit + 7) / 8; ++
i) {
75 bitset &
set(size_type
const & pos,
bool const & val =
true) {
80 for(size_type
i = 0;
i < (Nbit + 7) / 8; ++
i) {
93 for(size_type
i = 0;
i < (Nbit + 7) / 8; ++
i) {
106 return reference(array_[pos/8], pos % 8);
118 for(size_type
i = 0;
i < (Nbit + 7) / 8; ++
i) {
133 for(size_type
i = 0;
i < Nbit; ++
i) {
134 os << (*this)[Nbit -
i - 1];
137 template<
typename Archive>
142 uint8_t array_[(Nbit + 7) / 8];
145 #endif //__BITSET_HEADER
reference operator[](size_type const &pos)
Definition: bitset.hpp:103
bitset & set(size_type const &pos, bool const &val=true)
Definition: bitset.hpp:75
bitset & reset(size_type const &pos)
Definition: bitset.hpp:98
bitset & flip()
Definition: bitset.hpp:79
bool any() const
Definition: bitset.hpp:117
size_type size() const
Definition: bitset.hpp:114
bitset & operator=(bitset const &rhs)
Definition: bitset.hpp:62
void write_bit(T &unit, uint8_t const &pos, bool state=true)
Definition: byte_operation.hpp:48
bitset & flip(size_type const &pos)
Definition: bitset.hpp:85
void serialize(Archive &ar)
Definition: bitset.hpp:138
void flip_bit(T &unit, uint8_t const &pos)
Definition: byte_operation.hpp:52
bitset(bitset const &arg)
Definition: bitset.hpp:57
bitset & set()
Definition: bitset.hpp:69
Definition: bitset.hpp:19
bitset & operator~()
Definition: bitset.hpp:89
void print(S &os) const
Definition: bitset.hpp:132
bool none() const
Definition: bitset.hpp:124
bitset & reset()
Definition: bitset.hpp:92
size_type count() const
Definition: bitset.hpp:127
bool operator[](size_type const &pos) const
Definition: bitset.hpp:108
bool read_bit(T const &unit, uint8_t const &pos)
Definition: byte_operation.hpp:36
#define ASSERT(exp)
Definition: ard_assert.hpp:33
bitset()
Definition: bitset.hpp:54