73 Bit &operator = (
bool val) { _bm->
bit(_bit, val);
return *
this; }
74 operator bool ()
const {
return _bm->
bit(_bit); }
82 static long bit_buffer_bytes(
long bits)
throw()
90 typedef unsigned long Type;
98 static long chars(
long bits)
throw ()
102 template<
long BITS >
106 typedef unsigned char Type;
118 void bit(
long bit,
bool on)
throw();
129 void set_bit(
long bit)
throw();
136 word_type
bit(
long bit)
const throw();
144 {
return this->
bit(bit); }
152 {
return Bit(
this, bit); }
165 long scan_zero(
long max_bit,
long start_bit = 0)
const throw();
167 void *bit_buffer()
const throw() {
return _bits; }
170 static int _bzl(
unsigned long w)
throw();
189 { __builtin_memcpy(_bits, o._bits,
sizeof(_bits)); }
202 long scan_zero(
long start_bit = 0)
const throw();
205 { __builtin_memset(_bits, 0,
sizeof(_bits)); }
215 _bits[idx] = (_bits[idx] & ~(1UL << b)) | ((
unsigned long)on << b);
224 _bits[idx] &= ~(1UL << b);
233 _bits[idx] |= (1UL << b);
242 return _bits[idx] & (1UL << b);
247 Bitmap_base::_bzl(
unsigned long w)
throw()
249 for (
int i = 0; i < W_bits; ++i, w >>= 1)
261 if (!(
operator [] (start_bit)))
266 max_bit -= start_bit & ~(
W_bits - 1);
268 for (; max_bit > 0; max_bit -=
W_bits, ++idx)
273 if (_bits[idx] != ~0UL)
275 long zbit = _bzl(_bits[idx]);
276 return zbit < max_bit ? idx * W_bits + zbit : -1;
283 template<
int BITS>
inline
A writeable bit in a bitmap.
void clear_bit(long bit)
Clear bit bit.
void set_bit(long bit)
Set bit bit.
long scan_zero(long max_bit, long start_bit=0) const
Scan for the first zero bit.
Helper abstraction for a word contained in the bitmap.
Helper abstraction for a byte contained in the bitmap.
static unsigned word_index(unsigned bit)
Get the word index for the given bit.
static long words(long bits)
Get the number of Words that are used for the bitmap.
static unsigned bit_index(unsigned bit)
Get the bit index within word_type for the given bit.
number of bits in word_type
word_type operator[](long bit) const
Get the bit at index bit.
Bitmap()
Create a bitmap with BITS bits.
static long chars(long bits)
Get the number of chars that are used for the bitmap.
void bit(long bit, bool on)
Set the value of bit bit to on.
word_type * _bits
Pointer to the buffer storing the bits.
unsigned long word_type
Data type for each element of the bit buffer.
Basic bitmap abstraction.
long scan_zero(long start_bit=0) const
Scan for the first zero bit.