XPoint 0.1.0
Hardware-agnostic crosspoint matrix routing library
Loading...
Searching...
No Matches
BitPool Class Reference

#include <BitPool.h>

Public Member Functions

 BitPool (uint32_t nBits)
 Heap-owning constructor.
 
 BitPool (uint32_t *words, uint32_t nBits)
 Non-owning constructor.
 
 ~BitPool ()
 
 BitPool (const BitPool &)=delete
 
BitPooloperator= (const BitPool &)=delete
 
bool valid () const
 True if the pool has a valid (non-null) word array.
 
bool get (uint32_t n) const
 Read bit n.
 
void set (uint32_t n, bool v)
 Write bit n.
 
void clear ()
 Zero all words in the pool.
 

Static Public Member Functions

static uint16_t wordsFor (uint32_t nBits)
 Words required to hold nBits bits.
 

Constructor & Destructor Documentation

◆ BitPool() [1/3]

BitPool::BitPool ( uint32_t  nBits)
explicit

Heap-owning constructor.

Allocates wordsFor(nBits) uint32_t words and zeros them. The destructor frees the allocation.

Parameters
[in]nBitsTotal number of bits to store.

◆ BitPool() [2/3]

BitPool::BitPool ( uint32_t *  words,
uint32_t  nBits 
)

Non-owning constructor.

Uses a caller-supplied word array; the destructor does not free it. The array must contain at least wordsFor(nBits) elements and must outlive this object.

Parameters
[in]wordsPointer to the caller-owned word array.
[in]nBitsTotal number of bits the pool represents.

◆ ~BitPool()

BitPool::~BitPool ( )

◆ BitPool() [3/3]

BitPool::BitPool ( const BitPool )
delete

Member Function Documentation

◆ clear()

void BitPool::clear ( )

Zero all words in the pool.

◆ get()

bool BitPool::get ( uint32_t  n) const
inline

Read bit n.

No bounds check — caller must ensure n < nBits.

Returns
true if bit n is set, false otherwise.

◆ operator=()

BitPool & BitPool::operator= ( const BitPool )
delete

◆ set()

void BitPool::set ( uint32_t  n,
bool  v 
)
inline

Write bit n.

No bounds check — caller must ensure n < nBits.

Parameters
[in]nBit index.
[in]vValue to write.

◆ valid()

bool BitPool::valid ( ) const
inline

True if the pool has a valid (non-null) word array.

◆ wordsFor()

static uint16_t BitPool::wordsFor ( uint32_t  nBits)
inlinestatic

Words required to hold nBits bits.

Returns
0 for nBits == 0, otherwise ceil(nBits / 32).

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