template<unsigned int NUMBITS>
class Util::BitField< NUMBITS >
Implements large bit field.
The bit field occupies as little memory as possible, based on how many bits are required per the template parameter.
Will occupy 8, 16, 32 or 64 bits, or a multiple of 64 bits for larger fields.
- Copyright
- (C) 2009 Radon Labs GmbH (C) 2013-2020 Individual contributors, see AUTHORS file
|
| BitField () |
| constructor
|
|
constexpr | BitField (std::initializer_list< unsigned int > list) |
| constructs a bitfield based on multiple values
|
|
| BitField (const BitField< NUMBITS > &rhs)=default |
| copy constructor
|
|
constexpr bool | operator== (const BitField< NUMBITS > &rhs) const |
| equality operator
|
|
constexpr bool | operator!= (const BitField< NUMBITS > &rhs) const |
| inequality operator
|
|
constexpr bool | IsSet (const uint64_t bitIndex) const |
| Check if single bit is set.
|
|
template<uint64_t bitIndex> |
constexpr bool | IsSet () const |
| Check if single bit is set.
|
|
void | Clear () |
| clear content
|
|
bool | IsNull () const |
| return true if all bits are 0
|
|
constexpr void | SetBit (const uint64_t bitIndex) |
| set a bit by index
|
|
constexpr void | SetBitIf (const uint64_t bitIndex, uint64_t cond) |
| set a bit by index. Multiplies the bit with cond before OR-ing which means it won't set the bit if mul is 0, which makes it branchless.
|
|
template<uint64_t bitIndex> |
constexpr void | SetBit () |
| set a bit by index
|
|
void | ClearBit (const uint64_t bitIndex) |
| clear a bit by index
|
|
bool | SectionIsNull (uint64_t section) const |
| Check if a section of the bitfield is set.
|
|
template<unsigned int NUMBITS>
bool Util::BitField< NUMBITS >::SectionIsNull |
( |
uint64_t | section | ) |
const |
Check if a section of the bitfield is set.
The section size depends on the size of the bit field. If the bitfield is 8, 16 or 32 bits large, the section size is the same size as the bitfield, thus there's only one section. If the bitfield is 64 bits or larger, the section size is 64 bits per section.