PxBitMapBase#

Defined in include/foundation/PxBitMap.h

Classes#

Structs#

template<class Alloc = PxAllocatorTraits<PxU32>::Type>
class PxBitMapBase : protected PxReflectionAllocator<PxU32>#

Holds a bitmap with operations to set, reset or test individual bits.

We inhibit copy to prevent unintentional copies. If a copy is desired copy() should be used or alternatively a copy constructor implemented.

Public Functions

inline explicit PxBitMapBase(const PxEMPTY)#

Deserialization constructor

inline PxBitMapBase(const Alloc &alloc = Alloc())#
inline ~PxBitMapBase()#

Bitmap destructor

inline void release()#

Deallocates bitmap and sets word count to 0.

inline Alloc &getAllocator()#

Gets allocator used for bitmap alloction.

Returns:

Reference to allocator

inline bool growAndSet(PxU32 index)#

Extends the bitmap if necessary and sets bit at the given index.

Parameters:

index – Index of the bit to be set.

Returns:

True if operation succeeds, false otherwise.

inline bool growAndReset(PxU32 index)#

Extends the bitmap if necessary and clears bit at the given index.

Parameters:

index – Index of the bit to be cleared.

Returns:

True if operation succeeds, false otherwise.

inline PxIntBool boundedTest(PxU32 index) const#

Tests value of bit at the given index, if the index is in bounds.

Parameters:

index – Index of the bit to test.

Returns:

A value > 0 if the bit at the index is set and index is in bounds, 0 if the bit is not set or if index is out of bounds.

inline void boundedReset(PxU32 index)#

Clears the bit at the given index, if the index is in bounds.

Parameters:

index – Index of the bit to clear.

inline void set(PxU32 index)#

Sets the bit at the given index.

The index must be in bounds (i.e. index < getWordCount() * 32) or behavior is undefined.

Parameters:

index – Index of the bit to set.

inline void reset(PxU32 index)#

Clears bit at the given index.

The index must be in bounds (i.e. index < getWordCount() * 32) or behavior is undefined.

Parameters:

index – Index of the bit to clear.

inline PxIntBool test(PxU32 index) const#

Tests value of the bit at the given index.

The index must be in bounds (i.e. index < getWordCount() * 32) or behavior is undefined.

Parameters:

index – Index of the bit to test.

Returns:

A value > 0 if the bit at the index is set, 0 if the bit is not set.

inline PxU32 getNibbleFast(PxU32 nibIndex) const#

Returns the 4-bit value (nibble) at the given nibble index.

The nibble index must be in bounds (i.e. nibIndex < getWordCount() * 8) or behavior is undefined.

Parameters:

nibIndex – Index of the nibble to retrieve.

Returns:

The 4-bit value at the nibble index.

inline void andNibbleFast(PxU32 nibIndex, PxU32 mask)#

Performs a bitwise AND of the 4-bit value (nibble) at the given nibble index with the specified mask.

The nibble index must be in bounds (i.e. nibIndex < getWordCount() * 8) or behavior is undefined. Only the lower 4 bits of mask are relevant.

Parameters:
  • nibIndex – Index of the nibble to modify.

  • mask – 4-bit mask to AND with the nibble.

inline void orNibbleFast(PxU32 nibIndex, PxU32 mask)#

Performs a bitwise OR of the 4-bit value (nibble) at the given nibble index with the specified mask.

The nibble index must be in bounds (i.e. nibIndex < getWordCount() * 8) or behavior is undefined. Only the lower 4 bits of mask are relevant.

Parameters:
  • nibIndex – Index of the nibble to modify.

  • mask – 4-bit mask to OR with the nibble.

inline void clear()#

Clears bitmap.

inline bool resize(PxU32 newBitCount)#

Resizes the bitmap to hold at least the given number of bits.

Parameters:

newBitCount – The required bit capacity of the bitmap.

Returns:

True if the bitmap was successfully resized; false otherwise.

inline bool resizeAndClear(PxU32 newBitCount)#

Resizes the bitmap to hold at least the given number of bits and clears all bits.

Parameters:

newBitCount – The required bit capacity of the bitmap.

Returns:

True if operation succeeds, false otherwise.

inline void setEmpty()#

Sets bitmap empty by deallocating the bitmap data and setting word count to 0.

inline void setWords(PxU32 *map, PxU32 wordCount)#

Sets bitmap to external 32-bit word data, and marks the data as user owned.

Parameters:
  • map – Pointer to external 32-bit word data.

  • wordCount – Number of 32-bit words in the external data.

inline PxU32 size() const#

Returns the number of bits represented by the bitmap.

Returns:

Number of bits stored in the bitmap.

inline bool copy(const PxBitMapBase &a)#

Copies the contents of another bitmap, extending this bitmap if necessary.

After the call, this bitmap will hold at least as many bits as a. Bits beyond the size of a (if any) are cleared.

Parameters:

a – Source bitmap to copy from.

Returns:

True if the bitmap could be extended (if needed) and copied, false otherwise.

inline PxU32 count() const#

Counts the number of set bits in the bitmap.

Returns:

The number of bits set to 1.

inline PxU32 count(PxU32 start, PxU32 length) const#

Counts the number of set bits in a range of the bitmap.

The range starts at start and spans length bits. Bits outside the bounds of the bitmap are ignored.

Parameters:
  • start – Index of the first bit to test.

  • length – Number of bits to include in the count.

Returns:

The number of bits set to 1 in the specified range.

inline PxU32 findLast() const#

Returns the index of the highest set bit in the bitmap.

If no bits are set, this function returns 0! As a result, a return value of 0 is ambiguous and may also indicate that bit 0 is set.

Returns:

Index of the highest set bit, or 0 if no bits are set.

inline bool hasAnyBitSet() const#

Returns whether any bit is set in the bitmap.

Returns:

True if at least one bit is set; false otherwise.

template<class Combiner, class _>
inline bool combineInPlace(
const PxBitMapBase<_> &b,
)#
template<class Combiner, class _1, class _2>
inline bool combine(
const PxBitMapBase<_1> &a,
const PxBitMapBase<_2> &b,
)#
inline const PxU32 *getWords() const#
inline PxU32 *getWords()#
inline PxU32 getWordCount() const#
inline PxU32 isInUserMemory() const#

Protected Functions

inline bool extend(PxU32 size)#
inline bool extendUninitialized(PxU32 size)#
template<class Combiner>
inline bool combine1(
const PxU32 *words,
PxU32 length,
)#
template<class Combiner>
inline bool combine2(
const PxU32 *words1,
PxU32 length1,
const PxU32 *words2,
PxU32 length2,
)#

Protected Attributes

PxU32 *mMap#
PxU32 mWordCount#
PxAllocator mAllocator#
PxU8 mPadding[3]#

Protected Static Functions

static inline void *allocate(
size_t size,
const char *filename,
int line,
uint32_t *cookie = NULL,
)#
static inline void deallocate(void *ptr, uint32_t *cookie = NULL)#

Friends

friend class Iterator
struct AND#

Public Functions

inline PxU32 operator()(PxU32 a, PxU32 b)#
class Iterator#

Iterate over indices in a bitmap

This iterator is good because it finds the set bit without looping over the cached bits upto 31 times. However it does require a variable shift.

Public Functions

inline Iterator(const PxBitMapBase &map)#
inline Iterator &operator=(const Iterator &other)#
inline PxU32 getNext()#
inline void reset()#

Public Static Attributes

static const PxU32 DONE = 0xffffffff#
struct OR#

Public Functions

inline PxU32 operator()(PxU32 a, PxU32 b)#
class PxCircularIterator#

Public Functions

inline PxCircularIterator(const PxBitMapBase &map, PxU32 index)#
inline PxU32 getNext()#

Public Static Attributes

static const PxU32 DONE = 0xffffffff#
class PxLoopIterator#

Public Functions

inline PxLoopIterator(const PxBitMapBase &map)#
inline bool hasBits()#
inline PxU32 getNext()#
struct XOR#

Public Functions

inline PxU32 operator()(PxU32 a, PxU32 b)#