gwnavruntime/containers/bitfieldutils.h Source File
Go to the documentation of this file.
8 #ifndef Navigation_BitFieldUtils_H
9 #define Navigation_BitFieldUtils_H
19 static KY_INLINE
KyUInt32 GetWordIndex(
KyUInt32 bitIndex) {
return bitIndex >> 5; }
20 static KY_INLINE
KyUInt32 GetBitIndexInWord(
KyUInt32 bitIndex) {
return bitIndex & 0x1F; }
21 static KY_INLINE
KyUInt32 GetWordsCount(
KyUInt32 bitCount) {
return (bitCount + 31) >> 5; }
22 static KY_INLINE
KyUInt32 GetWordMaskFromBitIndex(
KyUInt32 bitIndex) {
return GetWordMask(GetBitIndexInWord(bitIndex)); }
24 static KY_INLINE
void SetBit(
KyUInt32& word,
KyUInt32 bitIndex) { word |= GetWordMaskFromBitIndex(bitIndex); }
25 static KY_INLINE
void UnsetBit(
KyUInt32& word,
KyUInt32 bitIndex) { word &= ~GetWordMaskFromBitIndex(bitIndex); }
26 static KY_INLINE
bool IsBitSet(
KyUInt32 word,
KyUInt32 bitIndex) {
return (word & GetWordMaskFromBitIndex(bitIndex)) != 0; }
28 static KY_INLINE
void SetBit(
KyUInt32* words,
KyUInt32 bitIndex) { SetBit(words[GetWordIndex(bitIndex)], bitIndex); }
29 static KY_INLINE
void UnsetBit(
KyUInt32* words,
KyUInt32 bitIndex) { UnsetBit(words[GetWordIndex(bitIndex)], bitIndex); }
30 static KY_INLINE
bool IsBitSet(
const KyUInt32* words,
KyUInt32 bitIndex) {
return IsBitSet(words[GetWordIndex(bitIndex)], bitIndex); }
36 static const KyUInt32 s_maskToIsolateBit[32] =
38 1, 1U << 1, 1U << 2, 1U << 3, 1U << 4, 1U << 5, 1U << 6, 1U << 7,
39 1U << 8, 1U << 9, 1U << 10, 1U << 11, 1U << 12, 1U << 13, 1U << 14, 1U << 15,
40 1U << 16, 1U << 17, 1U << 18, 1U << 19, 1U << 20, 1U << 21, 1U << 22, 1U << 23,
41 1U << 24, 1U << 25, 1U << 26, 1U << 27, 1U << 28, 1U << 29, 1U << 30, 1U << 31
44 return s_maskToIsolateBit[bitIndexInWord];
52 #endif // Navigation_BitFieldUtils_H
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36