Plasma Engine  2.0
Loading...
Searching...
No Matches
plBitfield< Container > Class Template Reference

A template interface, that turns any array class into a bitfield. More...

#include <Bitfield.h>

Classes

struct  ConstIterator
 

Public Member Functions

plUInt32 GetCount () const
 Returns the number of bits that this bitfield stores.
 
template<typename = void>
void SetCountUninitialized (plUInt32 uiBitCount)
 Resizes the Bitfield to hold the given number of bits. This version does NOT initialize new bits!
 
void SetCount (plUInt32 uiBitCount, bool bSetNew=false)
 Resizes the Bitfield to hold the given number of bits. If bSetNew is true, new bits are set to 1, otherwise they are cleared to 0.
 
bool IsEmpty () const
 Returns true, if the bitfield does not store any bits.
 
bool IsAnyBitSet (plUInt32 uiFirstBit=0, plUInt32 uiNumBits=0xFFFFFFFF) const
 Returns true, if the bitfield is not empty and any bit is 1.
 
bool IsNoBitSet (plUInt32 uiFirstBit=0, plUInt32 uiNumBits=0xFFFFFFFF) const
 Returns true, if the bitfield is empty or all bits are set to zero.
 
bool AreAllBitsSet (plUInt32 uiFirstBit=0, plUInt32 uiNumBits=0xFFFFFFFF) const
 Returns true, if the bitfield is not empty and all bits are set to one.
 
void Clear ()
 Discards all bits and sets count to zero.
 
void SetBit (plUInt32 uiBit)
 Sets the given bit to 1.
 
void ClearBit (plUInt32 uiBit)
 Clears the given bit to 0.
 
void SetBitValue (plUInt32 uiBit, bool bValue)
 Sets the given bit to 1 or 0 depending on the given value.
 
bool IsBitSet (plUInt32 uiBit) const
 Returns true, if the given bit is set to 1.
 
void ClearAllBits ()
 Clears all bits to 0.
 
void SetAllBits ()
 Sets all bits to 1.
 
void SetBitRange (plUInt32 uiFirstBit, plUInt32 uiNumBits)
 Sets the range starting at uiFirstBit up to (and including) uiLastBit to 1.
 
void ClearBitRange (plUInt32 uiFirstBit, plUInt32 uiNumBits)
 Clears the range starting at uiFirstBit up to (and including) uiLastBit to 0.
 
void Swap (plBitfield< Container > &other)
 Swaps two bitfields.
 
ConstIterator GetIterator () const
 Returns a constant iterator to the very first set bit. Note that due to the way iterating through bits is accelerated, changes to the bitfield while iterating through the bits has undefined behaviour.
 
ConstIterator GetEndIterator () const
 Returns an invalid iterator. Needed to support range based for loops.
 

Friends

struct ConstIterator
 

Detailed Description

template<class Container>
class plBitfield< Container >

A template interface, that turns any array class into a bitfield.

This class provides an interface to work with single bits, to store true/false values. The underlying container is configurable, though it must support random access and a 'SetCount' function and it must use elements of type plUInt32. In most cases a dynamic array should be used. For this case the plDynamicBitfield typedef is already available. There is also an plHybridBitfield typedef.


The documentation for this class was generated from the following files: