38#ifdef _GLIBCPP_BITSET_BITS_PER_WORD
39#define BITS_PER_WORD _GLIBCPP_BITSET_BITS_PER_WORD
41#define BITS_PER_WORD (CHAR_BIT*sizeof(unsigned long))
44#ifndef _GLIBCPP_BITSET_WORDS
45#define BITSET_WORDS(__n) \
46((__n) < 1 ? 1 : ((__n) + BITS_PER_WORD - 1)/BITS_PER_WORD)
48#define BITSET_WORDS(__n) _GLIBCPP_BITSET_WORDS(__n)
51#define MASK ULLONG_MAX
60 typedef unsigned long _ul;
107 operator bool()
const
140 {
return &
_data[ index ]; }
146 bool at (
size_t word,
unsigned long bitmask)
148 return static_cast<bool>(
_data[ word ] & bitmask );
169 for (
size_t i = 0; i <
_words; i++)
176 for (
size_t i = 0; i <
_words; i++)
183 for (
size_t i = 0; i <
_words; i++)
190 for (
size_t i = 0; i <
_words; i++)
219 unsigned char* c = (
unsigned char*)&wd;
220 unsigned short cnt = 0;
222 for(
unsigned int i = 0; i <
sizeof(
_ul); i++)
225 return (
unsigned int) cnt;
231 unsigned int cnt = 0;
233 for(
size_t i = 0; i <
_words; i++)
253 memcpy(
_data, srce, nbwrd *
sizeof(
_ul));
257 {
for(
unsigned int i = 0; i <
_words; i++)
_data[i] = 0UL; }
271 size_t start_w, end_w, start_l, end_l;
280 if(start_w != end_w) {
282 mask = (
MASK << start_l);
284 _data[ start_w ] &= ~mask;
285 tmpl = b.
_data[ start_w ] & mask;
287 _data[ start_w ] |= tmpl;
290 size_t k = start_w + 1;
302 _data[ end_w ] &= ~mask;;
303 tmpl = b.
_data[ end_w ] & mask;
305 _data[ end_w ] |= tmpl;
311 _data[ start_w ] &= ~mask;
312 tmpl = b.
_data[ start_w ] & mask;
314 _data[ start_w ] |= tmpl;
#define BITSET_WORDS(__n)
Definition: bitstring.h:45
#define MASK
Definition: bitstring.h:51
#define BITS_PER_WORD
Definition: bitstring.h:41
Definition: bitstring.h:63
reference(bitstring &bs, size_t pos)
Definition: bitstring.h:73
_ul * _word
Definition: bitstring.h:66
size_t _bitpos
Definition: bitstring.h:67
~reference()
Definition: bitstring.h:79
bool operator~() const
Definition: bitstring.h:103
reference & flip()
Definition: bitstring.h:111
reference & operator=(const reference &j)
Definition: bitstring.h:93
reference & operator=(bool x)
Definition: bitstring.h:83
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:56
static unsigned char _bit_count[256]
Definition: bitstring.h:328
bitstring(const bitstring &b)
Definition: bitstring.h:127
bool at(size_t word, unsigned long bitmask)
Definition: bitstring.h:146
bitstring operator|(const bitstring &x)
Definition: bitstring.h:202
unsigned int count()
Count number of set bits.
Definition: bitstring.h:229
bitstring & operator|=(const bitstring &x)
Definition: bitstring.h:174
unsigned long _ul
Definition: bitstring.h:60
size_t _words
Definition: bitstring.h:323
_ul * getword_atIdx(size_t index)
Definition: bitstring.h:139
bitstring operator&(const bitstring &x)
Definition: bitstring.h:195
reference operator[](size_t pos)
Definition: bitstring.h:151
unsigned int local_popcountl(_ul wd)
Counts number of one's in string using a bit table count.
Definition: bitstring.h:217
void reset()
Set all bits to 0.
Definition: bitstring.h:256
size_t size()
Definition: bitstring.h:142
void set(size_t n)
Set a bit to 1.
Definition: bitstring.h:240
size_t nb_words()
Definition: bitstring.h:144
bitstring operator~(void)
Definition: bitstring.h:188
size_t _size
Definition: bitstring.h:322
bitstring & operator^=(const bitstring &x)
Definition: bitstring.h:181
_ul * _data
Definition: bitstring.h:325
~bitstring()
Definition: bitstring.h:134
void set_data(_ul *srce, size_t nbwrd)
Copy bits from an array of unsigned long words.
Definition: bitstring.h:246
void flip(size_t n)
Flip the bit at n.
Definition: bitstring.h:243
bitstring & operator&=(const bitstring &x)
Definition: bitstring.h:167
_ul * getword_atPos(size_t pos)
Definition: bitstring.h:136
bitstring operator^(const bitstring &x)
Definition: bitstring.h:209
void copy(const bitstring &b, size_t word_pos)
Copy one word.
Definition: bitstring.h:264
bitstring(size_t length)
Definition: bitstring.h:120
void copy(const bitstring &b)
Unchecked copy, assumes we have sames sizes.
Definition: bitstring.h:260
void copy(const bitstring &b, size_t from, size_t to)
Definition: bitstring.h:267
bitstring & operator=(const bitstring &b)
Definition: bitstring.h:157