XII Release 0.1.0
Loading...
Searching...
No Matches
xiiBitfield< 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

xiiUInt32 GetCount () const
 Returns the number of bits that this bitfield stores.
 
template<typename = void>
void SetCountUninitialized (xiiUInt32 uiBitCount)
 Resizes the Bitfield to hold the given number of bits. This version does NOT initialize new bits!
 
void SetCount (xiiUInt32 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 (xiiUInt32 uiFirstBit=0, xiiUInt32 uiNumBits=0xFFFFFFFF) const
 Returns true, if the bitfield is not empty and any bit is 1.
 
bool IsNoBitSet (xiiUInt32 uiFirstBit=0, xiiUInt32 uiNumBits=0xFFFFFFFF) const
 Returns true, if the bitfield is empty or all bits are set to zero.
 
bool AreAllBitsSet (xiiUInt32 uiFirstBit=0, xiiUInt32 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 (xiiUInt32 uiBit)
 Sets the given bit to 1.
 
void ClearBit (xiiUInt32 uiBit)
 Clears the given bit to 0.
 
void SetBitValue (xiiUInt32 uiBit, bool bValue)
 Sets the given bit to 1 or 0 depending on the given value.
 
bool IsBitSet (xiiUInt32 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 (xiiUInt32 uiFirstBit, xiiUInt32 uiNumBits)
 Sets the range starting at uiFirstBit up to (and including) uiLastBit to 1.
 
void ClearBitRange (xiiUInt32 uiFirstBit, xiiUInt32 uiNumBits)
 Clears the range starting at uiFirstBit up to (and including) uiLastBit to 0.
 
void Swap (xiiBitfield< 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 xiiBitfield< 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 xiiUInt32. In most cases a dynamic array should be used. For this case the xiiDynamicBitfield alias is already available. There is also a xiiHybridBitfield alias.


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