gwnavruntime/containers/bitfieldfixedsize.h Source File
Go to the documentation of this file.
8 #ifndef Navigation_BitFieldFixedSize_H
9 #define Navigation_BitFieldFixedSize_H
18 class BitFieldFixedSize
21 BitFieldFixedSize() { UnsetAllBits(); }
23 void SetBit(
KyUInt32 index) { GetByteByGlobalIndex(index) |= (
KyUInt8) 1 << GetPosInElem(index); }
24 void UnsetBit(
KyUInt32 index) { GetByteByGlobalIndex(index) &= (
KyUInt8) ~(1 << GetPosInElem(index)); }
26 void UnsetAllBits() { memset(m_bytes,
'\0',
sizeof (m_bytes)); }
27 void SetAllBits() { memset(m_bytes,
'\xFF',
sizeof (m_bytes)); }
29 bool IsBitSet(
KyUInt32 index)
const {
return ((GetByteByGlobalIndex(index) >> GetPosInElem(index)) & 0x01) != 0; }
31 const KyUInt8& GetByteByGlobalIndex(
KyUInt32 index)
const {
return m_bytes[index / nbBitPerByte]; }
32 KyUInt8& GetByteByGlobalIndex(
KyUInt32 index) {
return m_bytes[index / nbBitPerByte]; }
35 enum { mask = 0x07, nbBitPerByte = 8};
36 enum { nbBytes = (N + 7) / 8 };
43 #endif // Navigation_BitFieldFixedSize_H
unsigned char KyUInt8
Type used internally to represent an unsigned 8-bit integer.
Definition: types.h:41
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36