Diligent Engine
Loading...
Searching...
No Matches
Diligent::DynamicBitSet Class Reference

#include <DynamicBitSet.hpp>

Public Member Functions

 DynamicBitSet (size_t BitCount)
 DynamicBitSet (const DynamicBitSet &Other)=default
 Creates an independent copy of Other.
 DynamicBitSet (DynamicBitSet &&Other) noexcept
 Moves the contents of Other and leaves it as an empty set.
DynamicBitSetoperator= (const DynamicBitSet &Other)
 Replaces this set with an independent copy of Other.
DynamicBitSetoperator= (DynamicBitSet &&Other) noexcept
size_t GetSize () const noexcept
 Returns the number of addressable bits in the set.
void Resize (size_t BitCount)
bool Test (size_t BitIndex) const noexcept
void Set (size_t BitIndex, bool Value=true) noexcept
void Reset (size_t BitIndex) noexcept
void ResetAll () noexcept
 Resets every bit in the set.
template<typename HandlerType>
void ForEachSetBit (HandlerType &&Handler) const

Detailed Description

Runtime-sized set of bits.

The initial number of bits is specified at construction and may subsequently be changed with Resize(). All bits are initially reset, as are bits added by Resize(). The class is not thread-safe; concurrent access requires external synchronization if any thread may modify the set. Copies are independent; moving leaves the source as a valid empty set. Self-move assignment is a no-op.

Constructor & Destructor Documentation

◆ DynamicBitSet()

Diligent::DynamicBitSet::DynamicBitSet ( size_t BitCount)
inlineexplicit

Creates a set containing BitCount reset bits.

Parameters
[in]BitCount- Number of addressable bits in the set. May be zero.

Member Function Documentation

◆ ForEachSetBit()

template<typename HandlerType>
void Diligent::DynamicBitSet::ForEachSetBit ( HandlerType && Handler) const
inline

Invokes Handler for every set bit in ascending index order.

Handler must be callable with one size_t argument containing the bit index. Modifying this bit set from Handler is not supported.

Parameters
[in]Handler- Function object invoked once for every set bit.

◆ operator=()

DynamicBitSet & Diligent::DynamicBitSet::operator= ( DynamicBitSet && Other)
inlinenoexcept

Replaces this set with the contents of Other and leaves it empty. Self-move assignment is a no-op.

◆ Reset()

void Diligent::DynamicBitSet::Reset ( size_t BitIndex)
inlinenoexcept

Resets the specified bit.

Parameters
[in]BitIndex- Bit index in the range [0, GetSize()).

◆ Resize()

void Diligent::DynamicBitSet::Resize ( size_t BitCount)
inline

Changes the number of addressable bits in the set.

Existing bits in the retained range preserve their values. Newly added bits are reset, and bits removed by shrinking are discarded.

Parameters
[in]BitCount- New number of addressable bits. May be zero.

◆ Set()

void Diligent::DynamicBitSet::Set ( size_t BitIndex,
bool Value = true )
inlinenoexcept

Assigns a value to the specified bit.

Parameters
[in]BitIndex- Bit index in the range [0, GetSize()).
[in]Value- New bit value. The default value is true.

◆ Test()

bool Diligent::DynamicBitSet::Test ( size_t BitIndex) const
inlinenoexcept

Tests whether the specified bit is set.

Parameters
[in]BitIndex- Bit index in the range [0, GetSize()).
Returns
True if the bit is set and false otherwise.