21 #ifndef COSA_BITSET_HH 22 #define COSA_BITSET_HH 39 __attribute__((always_inline))
56 const uint8_t*
bits()
const 65 __attribute__((always_inline))
67 memset(m_set, 0,
sizeof(m_set));
75 for (uint16_t i = 0; i <
sizeof(m_set); i++)
76 if (m_set[i] != 0)
return (
false);
86 return ((ix < N) ? ((m_set[ix /
CHARBITS] & _BV(ix & MASK)) != 0) :
false);
95 if (ix < N) m_set[ix /
CHARBITS] |= _BV(ix & MASK);
104 if (ix < N) m_set[ix /
CHARBITS] &= ~_BV(ix & MASK);
114 for (uint16_t i = 0; i <
sizeof(m_set); i++)
115 m_set[i] = rhs.m_set[i];
125 for (uint16_t i = 0; i <
sizeof(m_set); i++)
126 m_set[i] |= rhs.m_set[i];
136 for (uint16_t i = 0; i <
sizeof(m_set); i++)
137 m_set[i] &= ~rhs.m_set[i];
148 return (memcmp(m_set, rhs.m_set,
sizeof(m_set)) == 0);
159 for (uint16_t i = 0; i < N; i++)
160 outs << ((rhs.m_set[i /
CHARBITS] & _BV(i & MASK)) != 0);
166 static const uint8_t MASK = (
CHARBITS - 1);
172 uint8_t m_set[SET_MAX];
void operator-=(BitSet &rhs)
void operator+=(uint16_t ix)
void operator-=(uint16_t ix)
const uint8_t * bits() const
void operator+=(BitSet &rhs)
bool operator==(BitSet &rhs)
bool operator[](uint16_t ix) const
friend IOStream & operator<<(IOStream &outs, BitSet &rhs)
void operator=(BitSet &rhs)