sparrow 0.9.0
Loading...
Searching...
No Matches
sparrow::dynamic_bitset_base< B > Class Template Reference

Base class providing core functionality for dynamic bitset implementations. More...

#include <dynamic_bitset_base.hpp>

Public Types

using self_type = dynamic_bitset_base<B>
 This class type.
 
using storage_type = B
 Underlying storage container type.
 
using storage_type_without_cvrefpointer
 Storage type without CV/ref/pointer qualifiers.
 
using block_type = typename storage_type_without_cvrefpointer::value_type
 Type of each storage block (integral type)
 
using value_type = bool
 Type of individual bit values.
 
using reference = bitset_reference<self_type>
 Mutable reference to a bit.
 
using const_reference = bool
 Immutable reference to a bit (plain bool)
 
using size_type = typename storage_type_without_cvrefpointer::size_type
 Type for sizes and indices.
 
using difference_type = typename storage_type_without_cvrefpointer::difference_type
 Type for iterator differences.
 
using iterator = bitset_iterator<self_type, false>
 Mutable iterator type.
 
using const_iterator = bitset_iterator<self_type, true>
 Immutable iterator type.
 

Public Member Functions

constexpr size_type size () const noexcept
 Returns the number of bits in the bitset.
 
constexpr bool empty () const noexcept
 Checks if the bitset contains no bits.
 
constexpr size_type null_count () const noexcept
 Returns the number of bits set to false (null/invalid).
 
constexpr bool test (size_type pos) const
 Tests the value of a bit at the specified position.
 
constexpr void set (size_type pos, value_type value)
 Sets the value of a bit at the specified position.
 
constexpr const_reference at (size_type pos) const
 Accesses a bit with bounds checking.
 
constexpr reference at (size_type pos)
 Accesses a bit with bounds checking.
 
constexpr reference operator[] (size_type i)
 Accesses a bit without bounds checking.
 
constexpr const_reference operator[] (size_type i) const
 Accesses a bit without bounds checking.
 
constexpr block_typedata () noexcept
 Returns a pointer to the underlying block storage.
 
constexpr const block_typedata () const noexcept
 Returns a pointer to the underlying block storage.
 
constexpr size_type block_count () const noexcept
 Returns the number of storage blocks.
 
constexpr void swap (self_type &rhs) noexcept
 Swaps the contents with another bitset.
 
constexpr iterator begin ()
 Returns a mutable iterator to the first bit.
 
constexpr iterator end ()
 Returns a mutable iterator past the last bit.
 
constexpr const_iterator begin () const
 Returns an immutable iterator to the first bit.
 
constexpr const_iterator end () const
 Returns an immutable iterator past the last bit.
 
constexpr const_iterator cbegin () const
 Returns an immutable iterator to the first bit.
 
constexpr const_iterator cend () const
 Returns an immutable iterator past the last bit.
 
constexpr reference front ()
 Accesses the first bit.
 
constexpr const_reference front () const
 Accesses the first bit.
 
constexpr reference back ()
 Accesses the last bit.
 
constexpr const_reference back () const
 Accesses the last bit.
 
constexpr const storage_type_without_cvrefpointerbuffer () const noexcept
 Returns an immutable reference to the underlying buffer.
 
constexpr storage_type_without_cvrefpointerbuffer () noexcept
 Returns a mutable reference to the underlying buffer.
 
storage_type extract_storage () noexcept
 Extracts the underlying storage (move operation).
 

Static Public Member Functions

static constexpr size_type compute_block_count (size_type bits_count) noexcept
 Computes the number of blocks needed to store the specified number of bits.
 

Protected Member Functions

constexpr dynamic_bitset_base (storage_type buffer, size_type size)
 Constructs a bitset with the given storage and size.
 
constexpr dynamic_bitset_base (storage_type buffer, size_type size, size_type null_count)
 Constructs a bitset with the given storage, size, and null count.
 
constexpr ~dynamic_bitset_base ()=default
 
constexpr dynamic_bitset_base (const dynamic_bitset_base &)=default
 
constexpr dynamic_bitset_base (dynamic_bitset_base &&) noexcept=default
 
constexpr dynamic_bitset_baseoperator= (const dynamic_bitset_base &)=default
 
constexpr dynamic_bitset_baseoperator= (dynamic_bitset_base &&) noexcept=default
 
constexpr void resize (size_type n, value_type b=false)
 Resizes the bitset to contain n bits.
 
constexpr void clear () noexcept
 Removes all bits from the bitset.
 
constexpr iterator insert (const_iterator pos, value_type value)
 Inserts a single bit at the specified position.
 
constexpr iterator insert (const_iterator pos, size_type count, value_type value)
 Inserts multiple bits with the same value at the specified position.
 
template<std::input_iterator InputIt>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
constexpr iterator insert (const_iterator pos, InputIt first, InputIt last)
 Inserts bits from an iterator range at the specified position.
 
constexpr iterator insert (const_iterator pos, std::initializer_list< value_type > ilist)
 Inserts bits from an initializer list at the specified position.
 
constexpr iterator emplace (const_iterator pos, value_type value)
 Constructs a bit in-place at the specified position.
 
constexpr iterator erase (const_iterator pos)
 Removes a single bit at the specified position.
 
constexpr iterator erase (const_iterator first, const_iterator last)
 Removes bits in the specified range.
 
constexpr void push_back (value_type value)
 Adds a bit to the end of the bitset.
 
constexpr void pop_back ()
 Removes the last bit from the bitset.
 
constexpr void zero_unused_bits ()
 Clears any unused bits in the last storage block.
 
size_type count_non_null () const noexcept
 Counts the number of bits set to true.
 

Friends

class bitset_iterator< self_type, true >
 Const iterator needs access to internals.
 
class bitset_iterator< self_type, false >
 Mutable iterator needs access to internals.
 
class bitset_reference< self_type >
 Bit reference needs access to internals.
 

Detailed Description

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
class sparrow::dynamic_bitset_base< B >

Base class providing core functionality for dynamic bitset implementations.

This template class serves as the foundation for both dynamic_bitset and dynamic_bitset_view, providing a comprehensive API for manipulating sequences of bits stored in memory blocks. The key difference between derived classes is memory ownership: dynamic_bitset owns and manages its storage, while dynamic_bitset_view provides a non-owning view.

The class efficiently stores bits using blocks of integral types, with specialized algorithms for bit manipulation, counting, and iteration. It supports all standard container operations including insertion, deletion, resizing, and element access.

Template Parameters
BThe underlying storage type, which must be a random access range. Typically buffer<T> for owning storage or buffer_view<T> for non-owning views. The value_type of B must be an integral type used as storage blocks.
Note
This class tracks both the total size and null count for efficient validity checking in data processing scenarios where null/invalid values are common.
The class uses bit-level operations and assumes little-endian bit ordering within blocks.

Example usage through derived classes:

//Through dynamic_bitset (owning)
bits.set(50, true);
bool value = bits.test(50);
//Through dynamic_bitset_view (non-owning)
std::vector<std::uint8_t> buffer(16, 0);
view.set(64, true);
constexpr const storage_type_without_cvrefpointer & buffer() const noexcept
Returns an immutable reference to the underlying buffer.
A non-owning view to a dynamic size sequence of bits stored in external memory.
A dynamic size sequence of bits with efficient storage and manipulation operations.

Definition at line 68 of file dynamic_bitset_base.hpp.

Member Typedef Documentation

◆ block_type

template<typename B>
using sparrow::dynamic_bitset_base< B >::block_type = typename storage_type_without_cvrefpointer::value_type

Type of each storage block (integral type)

Definition at line 76 of file dynamic_bitset_base.hpp.

◆ const_iterator

template<typename B>
using sparrow::dynamic_bitset_base< B >::const_iterator = bitset_iterator<self_type, true>

Immutable iterator type.

Definition at line 87 of file dynamic_bitset_base.hpp.

◆ const_reference

template<typename B>
using sparrow::dynamic_bitset_base< B >::const_reference = bool

Immutable reference to a bit (plain bool)

Definition at line 80 of file dynamic_bitset_base.hpp.

◆ difference_type

template<typename B>
using sparrow::dynamic_bitset_base< B >::difference_type = typename storage_type_without_cvrefpointer::difference_type

Type for iterator differences.

Definition at line 83 of file dynamic_bitset_base.hpp.

◆ iterator

template<typename B>
using sparrow::dynamic_bitset_base< B >::iterator = bitset_iterator<self_type, false>

Mutable iterator type.

Definition at line 86 of file dynamic_bitset_base.hpp.

◆ reference

template<typename B>
using sparrow::dynamic_bitset_base< B >::reference = bitset_reference<self_type>

Mutable reference to a bit.

Definition at line 79 of file dynamic_bitset_base.hpp.

◆ self_type

template<typename B>
using sparrow::dynamic_bitset_base< B >::self_type = dynamic_bitset_base<B>

This class type.

Definition at line 72 of file dynamic_bitset_base.hpp.

◆ size_type

template<typename B>
using sparrow::dynamic_bitset_base< B >::size_type = typename storage_type_without_cvrefpointer::size_type

Type for sizes and indices.

Definition at line 81 of file dynamic_bitset_base.hpp.

◆ storage_type

template<typename B>
using sparrow::dynamic_bitset_base< B >::storage_type = B

Underlying storage container type.

Definition at line 73 of file dynamic_bitset_base.hpp.

◆ storage_type_without_cvrefpointer

template<typename B>
using sparrow::dynamic_bitset_base< B >::storage_type_without_cvrefpointer
Initial value:
std::remove_pointer_t<
std::remove_cvref_t<storage_type>>

Storage type without CV/ref/pointer qualifiers.

Definition at line 74 of file dynamic_bitset_base.hpp.

◆ value_type

template<typename B>
using sparrow::dynamic_bitset_base< B >::value_type = bool

Type of individual bit values.

Definition at line 78 of file dynamic_bitset_base.hpp.

Constructor & Destructor Documentation

◆ dynamic_bitset_base() [1/4]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
sparrow::dynamic_bitset_base< B >::dynamic_bitset_base ( storage_type buffer,
size_type size )
constexprprotected

Constructs a bitset with the given storage and size.

Parameters
bufferThe storage buffer to use
sizeThe number of bits in the bitset
Postcondition
size() == size
null_count() is computed by counting unset bits

Definition at line 793 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dynamic_bitset_base() [2/4]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
sparrow::dynamic_bitset_base< B >::dynamic_bitset_base ( storage_type buffer,
size_type size,
size_type null_count )
constexprprotected

Constructs a bitset with the given storage, size, and null count.

Parameters
bufferThe storage buffer to use
sizeThe number of bits in the bitset
null_countThe number of unset bits
Precondition
null_count <= size
Postcondition
size() == size
null_count() == null_count

Definition at line 802 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ ~dynamic_bitset_base()

template<typename B>
sparrow::dynamic_bitset_base< B >::~dynamic_bitset_base ( )
constexprprotecteddefault

◆ dynamic_bitset_base() [3/4]

template<typename B>
sparrow::dynamic_bitset_base< B >::dynamic_bitset_base ( const dynamic_bitset_base< B > & )
constexprprotecteddefault

◆ dynamic_bitset_base() [4/4]

template<typename B>
sparrow::dynamic_bitset_base< B >::dynamic_bitset_base ( dynamic_bitset_base< B > && )
constexprprotecteddefaultnoexcept

Member Function Documentation

◆ at() [1/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::at ( size_type pos)
nodiscardconstexpr

Accesses a bit with bounds checking.

Parameters
posThe position of the bit to access
Returns
Mutable reference to the bit
Precondition
pos < size()
Postcondition
Return value allows modification of the bit at position pos
Exceptions
std::out_of_rangeif pos >= size()

Definition at line 725 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ at() [2/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::at ( size_type pos) const
nodiscardconstexpr

Accesses a bit with bounds checking.

Parameters
posThe position of the bit to access
Returns
Immutable reference to the bit value
Precondition
pos < size()
Postcondition
Return value represents the bit at position pos
Exceptions
std::out_of_rangeif pos >= size()

Definition at line 739 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ back() [1/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::back ( )
nodiscardconstexpr

Accesses the last bit.

Returns
Mutable reference to the last bit
Precondition
size() >= 1
Postcondition
Return value allows modification of the bit at position size()-1
Note
Asserts that the bitset is not empty in debug builds

Definition at line 773 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ back() [2/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::back ( ) const
nodiscardconstexpr

Accesses the last bit.

Returns
The value of the last bit
Precondition
size() >= 1
Postcondition
Return value represents the bit at position size()-1
Note
Asserts that the bitset is not empty in debug builds
Returns true for null buffers

Definition at line 781 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ begin() [1/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::begin ( )
nodiscardconstexpr

Returns a mutable iterator to the first bit.

Returns
Iterator pointing to the first bit
Postcondition
Return value points to position 0 or equals end() if empty

Definition at line 683 of file dynamic_bitset_base.hpp.

◆ begin() [2/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::begin ( ) const
nodiscardconstexpr

Returns an immutable iterator to the first bit.

Returns
Const iterator pointing to the first bit
Postcondition
Return value points to position 0 or equals end() if empty

Definition at line 697 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ block_count()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::block_count ( ) const
nodiscardconstexprnoexcept

Returns the number of storage blocks.

Returns
The number of blocks used to store the bits
Postcondition
Return value >= compute_block_count(size())

Definition at line 666 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ buffer() [1/2]

template<typename B>
const storage_type_without_cvrefpointer & sparrow::dynamic_bitset_base< B >::buffer ( ) const
inlinenodiscardconstexprnoexcept

Returns an immutable reference to the underlying buffer.

Returns
Reference to the storage buffer
Postcondition
Return value provides access to the underlying storage

Definition at line 286 of file dynamic_bitset_base.hpp.

Here is the caller graph for this function:

◆ buffer() [2/2]

template<typename B>
storage_type_without_cvrefpointer & sparrow::dynamic_bitset_base< B >::buffer ( )
inlinenodiscardconstexprnoexcept

Returns a mutable reference to the underlying buffer.

Returns
Reference to the storage buffer
Postcondition
Return value provides mutable access to the underlying storage

Definition at line 303 of file dynamic_bitset_base.hpp.

◆ cbegin()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::cbegin ( ) const
nodiscardconstexpr

Returns an immutable iterator to the first bit.

Returns
Const iterator pointing to the first bit
Postcondition
Return value points to position 0 or equals cend() if empty

Definition at line 711 of file dynamic_bitset_base.hpp.

Here is the caller graph for this function:

◆ cend()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::cend ( ) const
nodiscardconstexpr

Returns an immutable iterator past the last bit.

Returns
Const iterator pointing past the last bit
Postcondition
Return value points to position size()

Definition at line 718 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
void sparrow::dynamic_bitset_base< B >::clear ( )
constexprprotectednoexcept

Removes all bits from the bitset.

Postcondition
size() == 0
empty() == true
null_count() == 0

Definition at line 948 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ compute_block_count()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::compute_block_count ( size_type bits_count)
staticnodiscardconstexprnoexcept

Computes the number of blocks needed to store the specified number of bits.

Parameters
bits_countThe number of bits to store
Returns
The minimum number of blocks required
Postcondition
Return value >= (bits_count + bits_per_block - 1) / bits_per_block
Return value is 0 if bits_count is 0

Definition at line 811 of file dynamic_bitset_base.hpp.

Here is the caller graph for this function:

◆ count_non_null()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::count_non_null ( ) const
nodiscardprotectednoexcept

Counts the number of bits set to true.

Returns
The number of set bits
Postcondition
Return value <= size()
Return value == size() - null_count()
Note
Returns size() for null buffers (all bits assumed set)

Definition at line 840 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ data() [1/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::data ( ) const
nodiscardconstexprnoexcept

Returns a pointer to the underlying block storage.

Returns
Immutable pointer to the first block, or nullptr if storage is null
Postcondition
Return value points to valid memory or is nullptr

Definition at line 659 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ data() [2/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::data ( )
nodiscardconstexprnoexcept

Returns a pointer to the underlying block storage.

Returns
Mutable pointer to the first block, or nullptr if storage is null
Postcondition
Return value points to valid memory or is nullptr

Definition at line 645 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emplace()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
dynamic_bitset_base< B >::iterator sparrow::dynamic_bitset_base< B >::emplace ( const_iterator pos,
value_type value )
constexprprotected

Constructs a bit in-place at the specified position.

Parameters
posIterator pointing to the insertion position
valueThe value of the bit to emplace
Returns
Iterator pointing to the emplaced bit
Precondition
cbegin() <= pos <= cend()
Postcondition
size() increases by 1
Note
Equivalent to insert(pos, value) for bool values

Definition at line 1047 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ empty()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
bool sparrow::dynamic_bitset_base< B >::empty ( ) const
nodiscardconstexprnoexcept

Checks if the bitset contains no bits.

Returns
true if size() == 0, false otherwise
Postcondition
Return value is equivalent to (size() == 0)

Definition at line 558 of file dynamic_bitset_base.hpp.

Here is the caller graph for this function:

◆ end() [1/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::end ( )
nodiscardconstexpr

Returns a mutable iterator past the last bit.

Returns
Iterator pointing past the last bit
Postcondition
Return value points to position size()

Definition at line 690 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end() [2/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::end ( ) const
nodiscardconstexpr

Returns an immutable iterator past the last bit.

Returns
Const iterator pointing past the last bit
Postcondition
Return value points to position size()

Definition at line 704 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ erase() [1/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
dynamic_bitset_base< B >::iterator sparrow::dynamic_bitset_base< B >::erase ( const_iterator first,
const_iterator last )
constexprprotected

Removes bits in the specified range.

Parameters
firstIterator pointing to the first bit to remove
lastIterator pointing past the last bit to remove
Returns
Iterator pointing to the bit following the removed range
Precondition
cbegin() <= first <= last <= cend()
Postcondition
size() decreases by distance(first, last)
Note
Asserts that iterators form a valid range in debug builds

Definition at line 1065 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ erase() [2/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
dynamic_bitset_base< B >::iterator sparrow::dynamic_bitset_base< B >::erase ( const_iterator pos)
constexprprotected

Removes a single bit at the specified position.

Parameters
posIterator pointing to the bit to remove
Returns
Iterator pointing to the bit following the removed bit
Precondition
cbegin() <= pos < cend()
Postcondition
size() decreases by 1
Note
Asserts that pos is within valid range in debug builds

Definition at line 1054 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extract_storage()

template<typename B>
storage_type sparrow::dynamic_bitset_base< B >::extract_storage ( )
inlinenodiscardnoexcept

Extracts the underlying storage (move operation).

Returns
The moved storage object
Precondition
Storage type must be a value type (not a pointer or reference)
Postcondition
The bitset becomes invalid and should not be used after this call
Note
Only available when storage_type is the same as storage_type_without_cvrefpointer

Definition at line 331 of file dynamic_bitset_base.hpp.

◆ front() [1/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::front ( )
nodiscardconstexpr

Accesses the first bit.

Returns
Mutable reference to the first bit
Precondition
size() >= 1
Postcondition
Return value allows modification of the bit at position 0
Note
Asserts that the bitset is not empty in debug builds

Definition at line 753 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ front() [2/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::front ( ) const
nodiscardconstexpr

Accesses the first bit.

Returns
The value of the first bit
Precondition
size() >= 1
Postcondition
Return value represents the bit at position 0
Note
Asserts that the bitset is not empty in debug builds
Returns true for null buffers

Definition at line 761 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ insert() [1/4]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
template<std::input_iterator InputIt>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
dynamic_bitset_base< B >::iterator sparrow::dynamic_bitset_base< B >::insert ( const_iterator pos,
InputIt first,
InputIt last )
constexprprotected

Inserts bits from an iterator range at the specified position.

Template Parameters
InputItInput iterator type
Parameters
posIterator pointing to the insertion position
firstIterator pointing to the first bit to insert
lastIterator pointing past the last bit to insert
Returns
Iterator pointing to the first inserted bit
Precondition
cbegin() <= pos <= cend()
first and last form a valid iterator range
Postcondition
size() increases by distance(first, last)
Note
Asserts that pos is within valid range in debug builds

Definition at line 1002 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ insert() [2/4]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
dynamic_bitset_base< B >::iterator sparrow::dynamic_bitset_base< B >::insert ( const_iterator pos,
size_type count,
value_type value )
constexprprotected

Inserts multiple bits with the same value at the specified position.

Parameters
posIterator pointing to the insertion position
countThe number of bits to insert
valueThe value of the bits to insert
Returns
Iterator pointing to the first inserted bit
Precondition
cbegin() <= pos <= cend()
Postcondition
size() increases by count
All inserted bits have value 'value'
Note
Asserts that pos is within valid range in debug builds

Definition at line 966 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ insert() [3/4]

template<typename B>
iterator sparrow::dynamic_bitset_base< B >::insert ( const_iterator pos,
std::initializer_list< value_type > ilist )
constexprprotected

Inserts bits from an initializer list at the specified position.

Parameters
posIterator pointing to the insertion position
ilistInitializer list containing the bits to insert
Returns
Iterator pointing to the first inserted bit
Precondition
cbegin() <= pos <= cend()
Postcondition
size() increases by ilist.size()

◆ insert() [4/4]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
dynamic_bitset_base< B >::iterator sparrow::dynamic_bitset_base< B >::insert ( const_iterator pos,
value_type value )
constexprprotected

Inserts a single bit at the specified position.

Parameters
posIterator pointing to the insertion position
valueThe value of the bit to insert
Returns
Iterator pointing to the inserted bit
Precondition
cbegin() <= pos <= cend()
Postcondition
size() increases by 1
The bit at the returned iterator position has value 'value'
Note
Asserts that pos is within valid range in debug builds

Definition at line 958 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ null_count()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::null_count ( ) const
nodiscardconstexprnoexcept

Returns the number of bits set to false (null/invalid).

Returns
The count of unset bits
Postcondition
Return value <= size()

Definition at line 565 of file dynamic_bitset_base.hpp.

Here is the caller graph for this function:

◆ operator=() [1/2]

template<typename B>
dynamic_bitset_base & sparrow::dynamic_bitset_base< B >::operator= ( const dynamic_bitset_base< B > & )
constexprprotecteddefault

◆ operator=() [2/2]

template<typename B>
dynamic_bitset_base & sparrow::dynamic_bitset_base< B >::operator= ( dynamic_bitset_base< B > && )
constexprprotecteddefaultnoexcept

◆ operator[]() [1/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::operator[] ( size_type i)
nodiscardconstexpr

Accesses a bit without bounds checking.

Parameters
iThe position of the bit to access
Returns
Mutable reference to the bit
Precondition
i < size()
Postcondition
Return value allows modification of the bit at position i
Note
Asserts that i is within bounds in debug builds

Definition at line 572 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ operator[]() [2/2]

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
bool sparrow::dynamic_bitset_base< B >::operator[] ( size_type i) const
nodiscardconstexpr

Accesses a bit without bounds checking.

Parameters
iThe position of the bit to access
Returns
The value of the bit
Precondition
i < size()
Postcondition
Return value represents the bit at position i
Note
Asserts that i is within bounds in debug builds

Definition at line 580 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ pop_back()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
void sparrow::dynamic_bitset_base< B >::pop_back ( )
constexprprotected

Removes the last bit from the bitset.

Precondition
!empty()
Postcondition
size() decreases by 1 (if not empty)
Note
Does nothing if the bitset is empty

Definition at line 1109 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ push_back()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
void sparrow::dynamic_bitset_base< B >::push_back ( value_type value)
constexprprotected

Adds a bit to the end of the bitset.

Parameters
valueThe value of the bit to add
Postcondition
size() increases by 1
back() == value

Definition at line 1102 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:

◆ resize()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
void sparrow::dynamic_bitset_base< B >::resize ( size_type n,
value_type b = false )
constexprprotected

Resizes the bitset to contain n bits.

Parameters
nThe new size in bits
bThe value to initialize new bits with (default false)
Postcondition
size() == n
New bits (if any) are set to value b
Note
May allocate additional storage blocks if needed
Preserves existing bits when growing

Definition at line 909 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
void sparrow::dynamic_bitset_base< B >::set ( size_type pos,
value_type value )
constexpr

Sets the value of a bit at the specified position.

Parameters
posThe position of the bit to set
valueThe value to set (true or false)
Precondition
pos < size()
Postcondition
test(pos) == value
Note
Asserts that pos is within bounds in debug builds
May allocate storage if setting false on a null buffer and storage supports resize
Exceptions
std::runtime_errorif trying to set false on a non-resizable null buffer

Definition at line 606 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
auto sparrow::dynamic_bitset_base< B >::size ( ) const
nodiscardconstexprnoexcept

Returns the number of bits in the bitset.

Returns
The total number of bits stored
Postcondition
Return value is non-negative

Definition at line 551 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
void sparrow::dynamic_bitset_base< B >::swap ( self_type & rhs)
constexprnoexcept

Swaps the contents with another bitset.

Parameters
rhsThe other bitset to swap with
Postcondition
This bitset contains the former contents of rhs
rhs contains the former contents of this bitset

Definition at line 673 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
bool sparrow::dynamic_bitset_base< B >::test ( size_type pos) const
nodiscardconstexpr

Tests the value of a bit at the specified position.

Parameters
posThe position of the bit to test
Returns
true if the bit is set, false otherwise
Precondition
pos < size()
Note
Asserts that pos is within bounds in debug builds
Returns true for null buffers (all bits assumed set)

Definition at line 587 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zero_unused_bits()

template<typename B>
requires std::ranges::random_access_range<std::remove_pointer_t<B>>
void sparrow::dynamic_bitset_base< B >::zero_unused_bits ( )
constexprprotected

Clears any unused bits in the last storage block.

Postcondition
Unused bits in the last block are set to 0
Note
This ensures consistent behavior and correct bit counting

Definition at line 880 of file dynamic_bitset_base.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ bitset_iterator< self_type, false >

template<typename B>
friend class bitset_iterator< self_type, false >
friend

Mutable iterator needs access to internals.

Definition at line 542 of file dynamic_bitset_base.hpp.

◆ bitset_iterator< self_type, true >

template<typename B>
friend class bitset_iterator< self_type, true >
friend

Const iterator needs access to internals.

Definition at line 542 of file dynamic_bitset_base.hpp.

◆ bitset_reference< self_type >

template<typename B>
friend class bitset_reference< self_type >
friend

Bit reference needs access to internals.

Definition at line 542 of file dynamic_bitset_base.hpp.


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