59 bool current =
m_array[bit / 8] & (1 << (bit % 8));
66 m_array[bit / 8] |= 1 << (bit % 8);
71 m_array[bit / 8] &= ~(1 << (bit % 8));
86 return m_array[bit / 8] & (1 << (bit % 8));
91 for (
Size i = from; i <= to; i++)
102 Size from = 0, found = 0;
113 i += (32 - (i % 32));
220 const Size bytes = bitCount / 8;
void setArray(u8 *array, const Size bitCount=ZERO)
Use the given pointer as the BitArray buffer.
u8 * array() const
Retrieve a pointer to the internal BitArray.
u8 * m_array
Array containing the bits.
void set(const Size bit, const bool value=true)
Sets the given bit to the given value.
Size m_set
Set bits in the array.
Size calculateBitmapSize(const Size bitCount) const
Calculate required size of bitmap array in bytes.
Size m_bitCount
Total number of bits in the array.
bool isSet(const Size bit) const
Verify if a given bit is set.
bool operator[](const Size bit) const
Retrieve the value of the given bit.
Size count(const bool on) const
Get the number of bits in the map which have the given value.
void unset(const Size bit)
Sets the given bit to zero.
virtual ~BitArray()
Class destructor.
BitArray(const Size bitCount, u8 *array=ZERO)
Class constructor.
void clear()
Set all bits to zero.
void setRange(const Size from, const Size to)
Set a range of bits inside the map to 1.
Result setNext(Size *bit, const Size count=1, const Size offset=0, const Size boundary=1)
Sets the next unset bit(s).
bool m_allocated
True if m_array was allocated interally.
Size size() const
Returns the maximum size of this Container.
static void * set(void *dest, int ch, unsigned count)
Fill memory with a constant byte.
#define assert(exp)
Insert program diagnostics.
unsigned int u32
Unsigned 32-bit number.
unsigned int Size
Any sane size indicator cannot go negative.
unsigned char u8
Unsigned 8-bit number.