Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cBitArrayStatic Class Reference

#include <cBitArray.h>

Inheritance diagram for GrayLib::cBitArrayStatic:
Gray::cBits GrayLib::cBitArray GrayLib::cBigUnsigned GrayLib::cBigInteger

Public Types

typedef UINT32 BLOCK_t
 The biggest unsigned type I can do atomic math on for this architecture. More...
 
typedef INT32 BLOCKI_t
 The biggest signed type I can do atomic math on. More...
 
typedef WORD BLOCKH_t
 half sized BLOCK_t for multiplication overflows. More...
 
typedef unsigned int BLOCK_ENUM_t
 Type for the index of a BLOCK_t in the array. NOT bits BIT_ENUM_t. More...
 

Public Member Functions

 cBitArrayStatic () noexcept
 
 cBitArrayStatic (BIT_ENUM_t nBits)
 
 cBitArrayStatic (BIT_ENUM_t nBits, BLOCK_t uValueMask)
 
 cBitArrayStatic (BLOCK_ENUM_t nBlocks, const BLOCK_t *pData)
 
 cBitArrayStatic (BLOCK_ENUM_t nBlocks, const BLOCK_t *pBlocksInit, bool bStatic)
 
 cBitArrayStatic (const THIS_t &ref)
 
 cBitArrayStatic (THIS_t &&ref) noexcept
 
 ~cBitArrayStatic ()
 
bool isNullVal () const noexcept
 
bool isZeroVal () const noexcept
 
BLOCK_ENUM_t get_BlocksCap () const noexcept
 
size_t get_BytesCap () const noexcept
 
BLOCK_t GetBlockInt (BLOCK_ENUM_t i) const
 
const BLOCK_tget_BlockPtrC () const noexcept
 
BLOCK_tget_BlockPtr ()
 
BLOCK_tRefBlockInt (BLOCK_ENUM_t i)
 
UINT32 GetU32Int (BLOCK_ENUM_t j) const
 
void SetU32Int (BLOCK_ENUM_t j, UINT32 val32)
 
const THIS_toperator= (const THIS_t &ref)
 
THIS_toperator= (THIS_t &&ref)
 
bool isStatic () const noexcept
 
void SetBlocksStatic (BLOCK_ENUM_t nBlocks, const BLOCK_t *pBlocks)
 
bool isReadOnly () const noexcept
 
BIT_ENUM_t get_BitsCap () const noexcept
 
bool IsValidBit (BIT_ENUM_t nBit) const noexcept
 
bool IsSet (BIT_ENUM_t nBit) const
 
bool isOdd () const
 
void ClrBit (BIT_ENUM_t nBit)
 
void SetBit (BIT_ENUM_t nBit)
 
bool SetBitRet (BIT_ENUM_t nBit)
 
void ModBit (BIT_ENUM_t nBit, bool bVal)
 
void SetNullVal () noexcept
 
void SetZeroAll ()
 
void SetAll1 ()
 
void SetBitsSizeZ (BIT_ENUM_t nBits)
 
void SetInvertBytes (size_t nSize)
 
void SetCopyBits (const THIS_t &ref)
 

Static Public Member Functions

static BLOCK_ENUM_t GetBlocksFromBits (BIT_ENUM_t nBits) noexcept
 
static BLOCK_ENUM_t GetBlocksFromBytes (size_t nBytes) noexcept
 
static bool IsReasonableBlockQty (BLOCK_ENUM_t nBlocks) noexcept
 
- Static Public Member Functions inherited from Gray::cBits
static constexpr size_t GetSizeBytes (BIT_ENUM_t nBits) noexcept
 
template<typename TYPE >
static constexpr TYPE Mask1 (BIT_ENUM_t nBit) noexcept
 
template<typename TYPE >
static constexpr bool IsMask1 (TYPE nVal) noexcept
 
template<typename TYPE >
static constexpr bool IsSet (TYPE nVal, BIT_ENUM_t nBit) noexcept
 
template<typename TYPE >
static constexpr bool IsClear (TYPE nVal, BIT_ENUM_t nBit) noexcept
 
template<typename TYPE >
static constexpr TYPE SetBit (TYPE nVal, BIT_ENUM_t nBit) noexcept
 
template<typename TYPE >
static constexpr TYPE ClearBit (TYPE nVal, BIT_ENUM_t nBit) noexcept
 
template<typename TYPE >
static constexpr bool HasMask (TYPE nVal, TYPE nMask) noexcept
 
template<typename TYPE >
static BIT_ENUM_t Highest1Bit (TYPE nMask) noexcept
 
template<typename TYPE >
static BIT_ENUM_t Count1Bits (TYPE nMask) noexcept
 
template<typename TYPE >
static TYPE Rotl (TYPE nVal, BIT_ENUM_t nBits) noexcept
 
template<typename TYPE >
static TYPE Rotr (TYPE nVal, BIT_ENUM_t nBits) noexcept
 
template<typename TYPE >
static TYPE Reverse (TYPE nVal) noexcept
 
template<>
BIT_ENUM_t Count1Bits (UINT32 nVal) noexcept
 
template<>
BYTE Reverse (BYTE nVal) noexcept
 
template<>
UINT32 Reverse (UINT32 nVal) noexcept
 
template<>
ULONG Reverse (ULONG nVal) noexcept
 

Static Public Attributes

static const BLOCK_ENUM_t k_BLOCK_MAX = 8096
 Arbitrary Max reasonable size. More...
 
static const size_t k_SIZE_MAX = k_BLOCK_MAX * sizeof(BLOCK_t)
 
static const BIT_ENUM_t k_BIT_MAX = k_SIZE_MAX * 8
 
static const cBitArrayStatic k_Zero
 
static const BLOCK_t k_OneBlock = 1
 
static const BIT_ENUM_t k_BLOCK_BITS = (BIT_ENUM_t)(sizeof(BLOCK_t) * 8)
 The number of bits in a BLOCK_t, BIT_ENUM_t. More...
 
static const BIT_ENUM_t k_BLOCKH_BITS = (BIT_ENUM_t)(sizeof(BLOCKH_t) * 8)
 The number of bits in a BLOCKH_t, BIT_ENUM_t. More...
 
- Static Public Attributes inherited from Gray::cBits
static const BYTE k_8 = 8
 represent the 8 bits in a byte. BIT_ENUM_t More...
 

Protected Member Functions

bool IsValidBlockIndex (BLOCK_ENUM_t i) const noexcept
 
void SetBlockSizeReAlloc (BLOCK_ENUM_t nBlocksNew)
 
void SetBlockSizeUninit (BLOCK_ENUM_t nBlocksNew)
 
void SetBlockSizeGrow (BLOCK_ENUM_t nBlocksNew)
 
BLOCK_ENUM_t FindUsedBlocksQty (BLOCK_ENUM_t nBlocks) const
 
BLOCK_ENUM_t FindUsedBlocksQty () const
 

Detailed Description

An arbitrary sized array of boolean values. Large Bit array that does NOT dynamically resize.

Member Typedef Documentation

◆ BLOCK_ENUM_t

Type for the index of a BLOCK_t in the array. NOT bits BIT_ENUM_t.

◆ BLOCK_t

The biggest unsigned type I can do atomic math on for this architecture.

◆ BLOCKH_t

half sized BLOCK_t for multiplication overflows.

◆ BLOCKI_t

The biggest signed type I can do atomic math on.

Constructor & Destructor Documentation

◆ cBitArrayStatic() [1/7]

GrayLib::cBitArrayStatic::cBitArrayStatic ( )
inlinenoexcept

construct empty.

◆ cBitArrayStatic() [2/7]

GrayLib::cBitArrayStatic::cBitArrayStatic ( BIT_ENUM_t  nBits)
inlineexplicit

◆ cBitArrayStatic() [3/7]

GrayLib::cBitArrayStatic::cBitArrayStatic ( BIT_ENUM_t  nBits,
BLOCK_t  uValueMask 
)
inline

Init just the first blocks bits with uValueMask. Small value.

◆ cBitArrayStatic() [4/7]

GrayLib::cBitArrayStatic::cBitArrayStatic ( BLOCK_ENUM_t  nBlocks,
const BLOCK_t pData 
)
inline

◆ cBitArrayStatic() [5/7]

GrayLib::cBitArrayStatic::cBitArrayStatic ( BLOCK_ENUM_t  nBlocks,
const BLOCK_t pBlocksInit,
bool  bStatic 
)
inline

◆ cBitArrayStatic() [6/7]

GrayLib::cBitArrayStatic::cBitArrayStatic ( const THIS_t ref)
inline

◆ cBitArrayStatic() [7/7]

GrayLib::cBitArrayStatic::cBitArrayStatic ( THIS_t &&  ref)
inlinenoexcept

move constructor

◆ ~cBitArrayStatic()

GrayLib::cBitArrayStatic::~cBitArrayStatic ( )
inline

free if ! m_bStatic

Member Function Documentation

◆ ClrBit()

void GrayLib::cBitArrayStatic::ClrBit ( BIT_ENUM_t  nBit)
inline

The size does NOT auto shrink/grow.

◆ FindUsedBlocksQty() [1/2]

BLOCK_ENUM_t GrayLib::cBitArrayStatic::FindUsedBlocksQty ( ) const
inlineprotected

Find the highest non zero block. AKA get_BlocksUse() _DEBUG usage only?

◆ FindUsedBlocksQty() [2/2]

BLOCK_ENUM_t GrayLib::cBitArrayStatic::FindUsedBlocksQty ( BLOCK_ENUM_t  nBlocks) const
inlineprotected

Find the highest non zero block. _DEBUG usage only?

◆ get_BitsCap()

BIT_ENUM_t GrayLib::cBitArrayStatic::get_BitsCap ( ) const
inlinenoexcept

Get Max bits declared.

◆ get_BlockPtr()

BLOCK_t* GrayLib::cBitArrayStatic::get_BlockPtr ( )
inline

Get a pointer I could modify. Dangerous !!

◆ get_BlockPtrC()

const BLOCK_t* GrayLib::cBitArrayStatic::get_BlockPtrC ( ) const
inlinenoexcept

Get a pointer I could read. slightly dangerous.

◆ get_BlocksCap()

BLOCK_ENUM_t GrayLib::cBitArrayStatic::get_BlocksCap ( ) const
inlinenoexcept

Get Max blocks i could use. allocated

◆ get_BytesCap()

size_t GrayLib::cBitArrayStatic::get_BytesCap ( ) const
inlinenoexcept

◆ GetBlockInt()

BLOCK_t GrayLib::cBitArrayStatic::GetBlockInt ( BLOCK_ENUM_t  i) const
inline

◆ GetBlocksFromBits()

static BLOCK_ENUM_t GrayLib::cBitArrayStatic::GetBlocksFromBits ( BIT_ENUM_t  nBits)
inlinestaticnoexcept

Number of blocks to hold this many bits. round up.

◆ GetBlocksFromBytes()

static BLOCK_ENUM_t GrayLib::cBitArrayStatic::GetBlocksFromBytes ( size_t  nBytes)
inlinestaticnoexcept

Number of blocks to hold this many bytes. round up.

◆ GetU32Int()

UINT32 GrayLib::cBitArrayStatic::GetU32Int ( BLOCK_ENUM_t  j) const
inline

Treat blocks as an array of UINT32.

◆ isNullVal()

bool GrayLib::cBitArrayStatic::isNullVal ( ) const
inlinenoexcept

◆ isOdd()

bool GrayLib::cBitArrayStatic::isOdd ( ) const
inline

◆ isReadOnly()

bool GrayLib::cBitArrayStatic::isReadOnly ( ) const
inlinenoexcept

isStatic does not necessarily mean read only. If the blocks are in read only memory. CPU memory protection will just throw its own exception if we try to modify it..

◆ IsReasonableBlockQty()

static bool GrayLib::cBitArrayStatic::IsReasonableBlockQty ( BLOCK_ENUM_t  nBlocks)
inlinestaticnoexcept

check for a max reasonable size.

◆ IsSet()

bool GrayLib::cBitArrayStatic::IsSet ( BIT_ENUM_t  nBit) const
inline

Gets the state of the enumerated bit. which has value 2^nBit. Bits beyond get_BitsCap are considered to be 0.

◆ isStatic()

bool GrayLib::cBitArrayStatic::isStatic ( ) const
inlinenoexcept

I don't free this. but i might be able to modify it. (mapped into stack/static space)

◆ IsValidBit()

bool GrayLib::cBitArrayStatic::IsValidBit ( BIT_ENUM_t  nBit) const
inlinenoexcept

Might i set/read this bit?

◆ IsValidBlockIndex()

bool GrayLib::cBitArrayStatic::IsValidBlockIndex ( BLOCK_ENUM_t  i) const
inlineprotectednoexcept

◆ isZeroVal()

bool GrayLib::cBitArrayStatic::isZeroVal ( ) const
inlinenoexcept

◆ ModBit()

void GrayLib::cBitArrayStatic::ModBit ( BIT_ENUM_t  nBit,
bool  bVal 
)
inline

Sets the state of bit to bVal The size does NOT auto shrink/grow.

◆ operator=() [1/2]

const THIS_t& GrayLib::cBitArrayStatic::operator= ( const THIS_t ref)
inline

assignment operator

◆ operator=() [2/2]

THIS_t& GrayLib::cBitArrayStatic::operator= ( THIS_t &&  ref)
inline

move assignment operator

◆ RefBlockInt()

BLOCK_t& GrayLib::cBitArrayStatic::RefBlockInt ( BLOCK_ENUM_t  i)
inline

Get a reference I could modify. MUST call UpdateBlocksUse() at some point after this. ASSUME we already have this many blocks.

◆ SetAll1()

void GrayLib::cBitArrayStatic::SetAll1 ( )
inline

Set all bits to 1.

◆ SetBit()

void GrayLib::cBitArrayStatic::SetBit ( BIT_ENUM_t  nBit)
inline

Set a bit true in known valid bit range. no grow.

◆ SetBitRet()

bool GrayLib::cBitArrayStatic::SetBitRet ( BIT_ENUM_t  nBit)

Set a bit and return the previous value.

Note
The size does NOT auto shrink/grow.
Returns
Previous value.

◆ SetBitsSizeZ()

void GrayLib::cBitArrayStatic::SetBitsSizeZ ( BIT_ENUM_t  nBits)
inline

Create New/Clear/Zeroed bit array to hold nBits.

◆ SetBlockSizeGrow()

void GrayLib::cBitArrayStatic::SetBlockSizeGrow ( BLOCK_ENUM_t  nBlocksNew)
protected

Grow Size. Zero fill new. but leave existing.

◆ SetBlockSizeReAlloc()

void GrayLib::cBitArrayStatic::SetBlockSizeReAlloc ( BLOCK_ENUM_t  nBlocksNew)
protected

Keep any existing data. resize. I intend to modify this.

◆ SetBlockSizeUninit()

void GrayLib::cBitArrayStatic::SetBlockSizeUninit ( BLOCK_ENUM_t  nBlocksNew)
protected

◆ SetBlocksStatic()

void GrayLib::cBitArrayStatic::SetBlocksStatic ( BLOCK_ENUM_t  nBlocks,
const BLOCK_t pBlocks 
)

Set to some static value. ASSERT if nBlocks is not a reasonable size.

◆ SetCopyBits()

void GrayLib::cBitArrayStatic::SetCopyBits ( const THIS_t ref)

◆ SetInvertBytes()

void GrayLib::cBitArrayStatic::SetInvertBytes ( size_t  nSize)

◆ SetNullVal()

void GrayLib::cBitArrayStatic::SetNullVal ( )
noexcept

◆ SetU32Int()

void GrayLib::cBitArrayStatic::SetU32Int ( BLOCK_ENUM_t  j,
UINT32  val32 
)
inline

Treat blocks as an array of UINT32.

◆ SetZeroAll()

void GrayLib::cBitArrayStatic::SetZeroAll ( )
inline

Set all bits to 0. cMem::Zero(m_pBlocks, get_BytesCap());

Member Data Documentation

◆ k_BIT_MAX

const BIT_ENUM_t GrayLib::cBitArrayStatic::k_BIT_MAX = k_SIZE_MAX * 8
static

◆ k_BLOCK_BITS

const BIT_ENUM_t GrayLib::cBitArrayStatic::k_BLOCK_BITS = (BIT_ENUM_t)(sizeof(BLOCK_t) * 8)
static

The number of bits in a BLOCK_t, BIT_ENUM_t.

◆ k_BLOCK_MAX

const BLOCK_ENUM_t GrayLib::cBitArrayStatic::k_BLOCK_MAX = 8096
static

Arbitrary Max reasonable size.

◆ k_BLOCKH_BITS

const BIT_ENUM_t GrayLib::cBitArrayStatic::k_BLOCKH_BITS = (BIT_ENUM_t)(sizeof(BLOCKH_t) * 8)
static

The number of bits in a BLOCKH_t, BIT_ENUM_t.

◆ k_OneBlock

const BLOCK_t GrayLib::cBitArrayStatic::k_OneBlock = 1
static

◆ k_SIZE_MAX

const size_t GrayLib::cBitArrayStatic::k_SIZE_MAX = k_BLOCK_MAX * sizeof(BLOCK_t)
static

◆ k_Zero

const cBitArrayStatic GrayLib::cBitArrayStatic::k_Zero
static

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