Implements a growable bit array (similar to std::vector<bool>).
Unlike BitField, which is sized at compile time, this grows when a bit outside it is set, which is what makes it usable for a flag per item when the number of items is not known in advance, for example a flag per entity or per instance of a runtime structure.
The storage is one 64 bit word per 64 bits, so a whole section can be skipped with a single word check before any bit is looked at.
- Copyright
- (C) 2026 Individual contributors, see AUTHORS file
|
| | BitArray () |
| | constructor
|
| | ~BitArray () |
| | destructor
|
| void | Resize (uint64_t numBits) |
| | resize to a number of bits. Growing keeps the bits which are already set, shrinking is not supported
|
| void | EnsureBit (uint64_t bitIndex) |
| | make a bit addressable, growing the array when it is outside
|
| void | SetBit (const uint64_t bitIndex) |
| | set a bit by index, growing the array when the index is outside it
|
| void | ClearBit (const uint64_t bitIndex) |
| | clear a bit by index. Does nothing when the index is outside the array
|
| bool | IsSet (const uint64_t bitIndex) const |
| | check a bit by index. False when the index is outside the array
|
| void | MoveBit (const uint64_t from, const uint64_t to) |
| | move a bit from one index to another. The source is cleared and the target gets the value
|
| bool | IsNull () const |
| | true when no bit is set
|
| bool | SectionIsNull (const uint64_t section) const |
| | true when a whole 64 bit section is empty
|
| SizeT | NumSections () const |
| | number of 64 bit sections which are allocated
|
| IndexT | FirstSetBitInSection (const uint64_t section) const |
| | the index of the first set bit in a section, or InvalidIndex when the section is empty
|
| void | Clear () |
| | clear all bits. The allocated words are kept
|
| void | Reset () |
| | clear all bits and release the storage
|