BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
belfem::DynamicBitset Class Reference

Runtime-sized bitset; one bit per flag, packed into 64-bit words. More...

#include <cl_DynamicBitset.hpp>

Public Member Functions

 DynamicBitset (const index_t aNumberOfBits)
 Constructor: Initializes the bitset with the given number of bits.
 DynamicBitset (const DynamicBitset &aBitset)
 copy constructor
 DynamicBitset (DynamicBitset &&aBitset) noexcept
 move constructor
 ~DynamicBitset ()
 Destructor: Releases allocated memory.
index_t size () const
 Returns the number of bits in the bitset.
index_t memory () const
 Returns the number of 64-bit blocks used (memory size).
void reset (const index_t aPos)
 Resets (clears) the bit at the given position.
void reset ()
 Resets (clears) all bits.
void set (const index_t aPos)
 Sets the bit at the given position to 1.
void set (const index_t aPos, const bool aValue)
 Sets the bit at the given position to the specified value.
void flip (const index_t aPos)
 Flips (toggles) the bit at the given position.
void flip ()
 Flips all bits at once.
bool test (const index_t aPos) const
 Tests whether the bit at the given position is set.
index_t count () const
 Counts the number of bits set to 1.
const uint64_t * data () const
bool summaries_are_tight () const
void lock ()
 makes the bitset non-writable and computes the hash
void unlock ()
 makes the bitset writable and resets the hash
bool is_locked () const
 checks if the bitset is writable
size_t hash () const
 Returns a hash function for fast comparison.
string to_string () const
string to_hex () const
index_t to_int () const
string to_raw_string () const
void set_from_hex (const string &aString)
void set_index (const index_t aIndex)
index_t index () const
void where (Cell< index_t > &aBits, const bool aAssumeSparse=true) const
bool operator== (const DynamicBitset &aRhs) const
bool operator!= (const DynamicBitset &aRhs) const
 Comparison operator: Checks if two bitsets are not equal.
DynamicBitsetoperator= (const DynamicBitset &aRhs)
 Assignment operator.
DynamicBitsetoperator= (DynamicBitset &&aRhs) noexcept
 Move assignment operator.
DynamicBitset operator| (const DynamicBitset &aRhs) const
 Bitwise OR operator.
DynamicBitsetoperator|= (const DynamicBitset &aRhs)
 Assignment or operator.
DynamicBitset operator^ (const DynamicBitset &aRhs) const
 Bitwise XOR operator.
DynamicBitsetoperator^= (const DynamicBitset &aRhs)
 Bitwise XOR assignment operator.
DynamicBitset operator& (const DynamicBitset &aRhs) const
 Bitwise AND operator.
DynamicBitsetoperator&= (const DynamicBitset &aRhs)
 Bitwise AND assignment operator.

Detailed Description

Runtime-sized bitset; one bit per flag, packed into 64-bit words.

See also
BELFEM Container Classes - Usage Guide

Constructor & Destructor Documentation

◆ DynamicBitset() [1/3]

belfem::DynamicBitset::DynamicBitset ( const index_t aNumberOfBits)

Constructor: Initializes the bitset with the given number of bits.

◆ DynamicBitset() [2/3]

belfem::DynamicBitset::DynamicBitset ( const DynamicBitset & aBitset)

copy constructor

◆ DynamicBitset() [3/3]

belfem::DynamicBitset::DynamicBitset ( DynamicBitset && aBitset)
noexcept

move constructor

◆ ~DynamicBitset()

belfem::DynamicBitset::~DynamicBitset ( )

Destructor: Releases allocated memory.

Member Function Documentation

◆ count()

index_t belfem::DynamicBitset::count ( ) const

Counts the number of bits set to 1.

◆ data()

const uint64_t * belfem::DynamicBitset::data ( ) const
inline

Returns a pointer to the data array (const)

Note
there is deliberately no mutable overload: a write through one would bypass the summary bitmaps, after which where() and reset() silently miss the affected words. Mutate through set() / reset() / flip() instead.

◆ flip() [1/2]

void belfem::DynamicBitset::flip ( )

Flips all bits at once.

◆ flip() [2/2]

void belfem::DynamicBitset::flip ( const index_t aPos)
inline

Flips (toggles) the bit at the given position.

◆ hash()

size_t belfem::DynamicBitset::hash ( ) const
inline

Returns a hash function for fast comparison.

returns the hash value

◆ index()

index_t belfem::DynamicBitset::index ( ) const
inline

◆ is_locked()

bool belfem::DynamicBitset::is_locked ( ) const
inline

checks if the bitset is writable

◆ lock()

void belfem::DynamicBitset::lock ( )
inline

makes the bitset non-writable and computes the hash

◆ memory()

index_t belfem::DynamicBitset::memory ( ) const
inline

Returns the number of 64-bit blocks used (memory size).

◆ operator!=()

bool belfem::DynamicBitset::operator!= ( const DynamicBitset & aRhs) const
inline

Comparison operator: Checks if two bitsets are not equal.

◆ operator&()

DynamicBitset belfem::DynamicBitset::operator& ( const DynamicBitset & aRhs) const
inline

Bitwise AND operator.

◆ operator&=()

DynamicBitset & belfem::DynamicBitset::operator&= ( const DynamicBitset & aRhs)
inline

Bitwise AND assignment operator.

◆ operator=() [1/2]

DynamicBitset & belfem::DynamicBitset::operator= ( const DynamicBitset & aRhs)

Assignment operator.

◆ operator=() [2/2]

DynamicBitset & belfem::DynamicBitset::operator= ( DynamicBitset && aRhs)
noexcept

Move assignment operator.

◆ operator==()

bool belfem::DynamicBitset::operator== ( const DynamicBitset & aRhs) const
inline

Comparison operator: Checks if two bitsets are equal. Both bitsets must be locked: a debug build asserts on an unlocked operand, a release build compares the words regardless. A size mismatch is an error in every build.

◆ operator^()

DynamicBitset belfem::DynamicBitset::operator^ ( const DynamicBitset & aRhs) const
inline

Bitwise XOR operator.

◆ operator^=()

DynamicBitset & belfem::DynamicBitset::operator^= ( const DynamicBitset & aRhs)
inline

Bitwise XOR assignment operator.

◆ operator|()

DynamicBitset belfem::DynamicBitset::operator| ( const DynamicBitset & aRhs) const
inline

Bitwise OR operator.

◆ operator|=()

DynamicBitset & belfem::DynamicBitset::operator|= ( const DynamicBitset & aRhs)
inline

Assignment or operator.

◆ reset() [1/2]

void belfem::DynamicBitset::reset ( )

Resets (clears) all bits.

◆ reset() [2/2]

void belfem::DynamicBitset::reset ( const index_t aPos)
inline

Resets (clears) the bit at the given position.

◆ set() [1/2]

void belfem::DynamicBitset::set ( const index_t aPos)
inline

Sets the bit at the given position to 1.

◆ set() [2/2]

void belfem::DynamicBitset::set ( const index_t aPos,
const bool aValue )
inline

Sets the bit at the given position to the specified value.

◆ set_from_hex()

void belfem::DynamicBitset::set_from_hex ( const string & aString)

◆ set_index()

void belfem::DynamicBitset::set_index ( const index_t aIndex)
inline

◆ size()

index_t belfem::DynamicBitset::size ( ) const
inline

Returns the number of bits in the bitset.

◆ summaries_are_tight()

bool belfem::DynamicBitset::summaries_are_tight ( ) const

Diagnostic: checks that both summary levels are tight, i.e. that a summary bit is set exactly when the word below it is nonzero, and that no summary bit stands beyond its child array. Intended for tests and debugging; costs one pass over the data.

◆ test()

bool belfem::DynamicBitset::test ( const index_t aPos) const
inline

Tests whether the bit at the given position is set.

◆ to_hex()

std::string belfem::DynamicBitset::to_hex ( ) const

◆ to_int()

index_t belfem::DynamicBitset::to_int ( ) const
inline

◆ to_raw_string()

std::string belfem::DynamicBitset::to_raw_string ( ) const

◆ to_string()

string belfem::DynamicBitset::to_string ( ) const

◆ unlock()

void belfem::DynamicBitset::unlock ( )
inline

makes the bitset writable and resets the hash

◆ where()

void belfem::DynamicBitset::where ( Cell< index_t > & aBits,
const bool aAssumeSparse = true ) const
inline

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