4#pragma warning(disable : 4237)
41 m_bitset->Flip(m_offset);
49 bool operator~()
const {
return (!m_bitset->Test(m_offset)); }
55 operator bool()
const {
return (m_bitset->Test(m_offset)); }
86 m_blocks[p_bit / e_bitsPerBlock] ^= 1 << p_bit % e_bitsPerBlock;
113 return (m_blocks[p_bit / e_bitsPerBlock] & (1 << p_bit % e_bitsPerBlock)) != 0;
128 void Tidy(
MxU32 p_value = 0)
130 for (
MxS32 i = e_blocksRequired; i >= 0; --i) {
131 m_blocks[i] = p_value;
146 if (N % e_bitsPerBlock != 0) {
147 m_blocks[e_blocksRequired] &= ((1 << (N % e_bitsPerBlock)) - 1);
155 void Xran() { assert(
"invalid MxBitset<N> position" ==
NULL); }
163 e_bitsPerBlock = CHAR_BIT *
sizeof(
MxU32),
164 e_blocksRequired = N == 0 ? 0 : (N - 1) / e_bitsPerBlock
167 MxU32 m_blocks[e_blocksRequired + 1];
Proxy class to reference a single bit within the MxBitset.
bool operator~() const
Returns true if the referenced bit is not set.
Reference & Flip()
Flips the referenced bit (inverts its value).
Templated fixed-size bitset for bit manipulation.
MxU32 Size() const
Returns the number of bits (N) this bitset manages.
bool Test(MxU32 p_bit)
Tests if the given bit is set (1) or not (0).
Reference operator[](size_t p_bit)
Provides a reference-like object for a specific bit.
MxBitset()
Constructs an empty MxBitset with all bits cleared.
size_t Count()
Counts the number of set bits.
MxBitset< N > & Flip(size_t p_bit)
Flips (toggles) a single bit at the given position.
#define NULL
[AI] Null pointer value (C/C++ semantics).