sparrow 1.0.0
Loading...
Searching...
No Matches
sparrow::non_owning_dynamic_bitset< T > Class Template Reference

#include <non_owning_dynamic_bitset.hpp>

Inheritance diagram for sparrow::non_owning_dynamic_bitset< T >:
[legend]
Collaboration diagram for sparrow::non_owning_dynamic_bitset< T >:
[legend]

Public Types

using base_type = dynamic_bitset_base<buffer<T>*>
 
using storage_type = typename base_type::storage_type
 
using block_type = typename base_type::block_type
 
using value_type = typename base_type::value_type
 
using size_type = typename base_type::size_type
 
- Public Types inherited from sparrow::dynamic_bitset_base< buffer< T > * >
using self_type
 This class type.
 
using storage_type
 Underlying storage container type.
 
using storage_type_without_cvrefpointer
 Storage type without CV/ref/pointer qualifiers.
 
using block_type
 Type of each storage block (integral type)
 
using value_type
 Type of individual bit values.
 
using reference
 Mutable reference to a bit.
 
using const_reference
 Immutable reference to a bit (plain bool)
 
using size_type
 Type for sizes and indices.
 
using difference_type
 Type for iterator differences.
 
using iterator
 Mutable iterator type.
 
using const_iterator
 Immutable iterator type.
 

Public Member Functions

constexpr non_owning_dynamic_bitset (buffer< T > *buffer, size_type n)
 
constexpr ~non_owning_dynamic_bitset ()=default
 
constexpr non_owning_dynamic_bitset (const non_owning_dynamic_bitset &)=default
 
constexpr non_owning_dynamic_bitset (non_owning_dynamic_bitset &&) noexcept=default
 
constexpr non_owning_dynamic_bitsetoperator= (const non_owning_dynamic_bitset &)=default
 
constexpr non_owning_dynamic_bitsetoperator= (non_owning_dynamic_bitset &&) noexcept=default
 
constexpr void clear () noexcept
 Removes all bits from the bitset.
 
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 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.
 
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 void pop_back ()
 Removes the last bit from the bitset.
 
constexpr void push_back (value_type value)
 Adds a bit to the end of the bitset.
 
constexpr void resize (size_type n, value_type b=false)
 Resizes the bitset to contain n bits.
 
- Public Member Functions inherited from sparrow::dynamic_bitset_base< buffer< T > * >
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).
 
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 const_iterator begin () const
 Returns an immutable iterator to the first bit.
 
constexpr iterator end ()
 Returns a mutable iterator past the last 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).
 

Additional Inherited Members

- Static Public Member Functions inherited from sparrow::dynamic_bitset_base< buffer< T > * >
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.
 
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 inherited from sparrow::dynamic_bitset_base< buffer< T > * >
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.
 
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.
 
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 (const dynamic_bitset_base &)=default
 
constexpr dynamic_bitset_base (dynamic_bitset_base &&) noexcept=default
 
constexpr ~dynamic_bitset_base ()=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.
 
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.
 

Detailed Description

template<std::integral T>
class sparrow::non_owning_dynamic_bitset< T >

Definition at line 23 of file non_owning_dynamic_bitset.hpp.

Member Typedef Documentation

◆ base_type

template<std::integral T>
using sparrow::non_owning_dynamic_bitset< T >::base_type = dynamic_bitset_base<buffer<T>*>

Definition at line 27 of file non_owning_dynamic_bitset.hpp.

◆ block_type

template<std::integral T>
using sparrow::non_owning_dynamic_bitset< T >::block_type = typename base_type::block_type

Definition at line 29 of file non_owning_dynamic_bitset.hpp.

◆ size_type

template<std::integral T>
using sparrow::non_owning_dynamic_bitset< T >::size_type = typename base_type::size_type

Definition at line 31 of file non_owning_dynamic_bitset.hpp.

◆ storage_type

template<std::integral T>
using sparrow::non_owning_dynamic_bitset< T >::storage_type = typename base_type::storage_type

Definition at line 28 of file non_owning_dynamic_bitset.hpp.

◆ value_type

template<std::integral T>
using sparrow::non_owning_dynamic_bitset< T >::value_type = typename base_type::value_type

Definition at line 30 of file non_owning_dynamic_bitset.hpp.

Constructor & Destructor Documentation

◆ non_owning_dynamic_bitset() [1/3]

template<std::integral T>
sparrow::non_owning_dynamic_bitset< T >::non_owning_dynamic_bitset ( buffer< T > * buffer,
size_type n )
explicitconstexpr

Definition at line 52 of file non_owning_dynamic_bitset.hpp.

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

◆ ~non_owning_dynamic_bitset()

template<std::integral T>
sparrow::non_owning_dynamic_bitset< T >::~non_owning_dynamic_bitset ( )
constexprdefault

◆ non_owning_dynamic_bitset() [2/3]

template<std::integral T>
sparrow::non_owning_dynamic_bitset< T >::non_owning_dynamic_bitset ( const non_owning_dynamic_bitset< T > & )
constexprdefault

◆ non_owning_dynamic_bitset() [3/3]

template<std::integral T>
sparrow::non_owning_dynamic_bitset< T >::non_owning_dynamic_bitset ( non_owning_dynamic_bitset< T > && )
constexprdefaultnoexcept

Member Function Documentation

◆ clear()

template<std::integral T>
void sparrow::dynamic_bitset_base< buffer< T > * >::clear ( )
constexprnoexcept

Removes all bits from the bitset.

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

◆ emplace()

template<std::integral T>
iterator sparrow::dynamic_bitset_base< buffer< T > * >::emplace ( const_iterator pos,
value_type value )
constexpr

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

◆ erase() [1/2]

template<std::integral T>
iterator sparrow::dynamic_bitset_base< buffer< T > * >::erase ( const_iterator first,
const_iterator last )
constexpr

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

◆ erase() [2/2]

template<std::integral T>
iterator sparrow::dynamic_bitset_base< buffer< T > * >::erase ( const_iterator pos)
constexpr

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

◆ insert() [1/4]

template<std::integral T>
iterator sparrow::dynamic_bitset_base< buffer< T > * >::insert ( const_iterator pos,
InputIt first,
InputIt last )
constexpr

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

◆ insert() [2/4]

template<std::integral T>
iterator sparrow::dynamic_bitset_base< buffer< T > * >::insert ( const_iterator pos,
size_type count,
value_type value )
constexpr

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

◆ insert() [3/4]

template<std::integral T>
iterator sparrow::dynamic_bitset_base< buffer< T > * >::insert ( const_iterator pos,
std::initializer_list< value_type > ilist )
constexpr

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<std::integral T>
iterator sparrow::dynamic_bitset_base< buffer< T > * >::insert ( const_iterator pos,
value_type value )
constexpr

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

◆ operator=() [1/2]

template<std::integral T>
non_owning_dynamic_bitset & sparrow::non_owning_dynamic_bitset< T >::operator= ( const non_owning_dynamic_bitset< T > & )
constexprdefault

◆ operator=() [2/2]

template<std::integral T>
non_owning_dynamic_bitset & sparrow::non_owning_dynamic_bitset< T >::operator= ( non_owning_dynamic_bitset< T > && )
constexprdefaultnoexcept

◆ pop_back()

template<std::integral T>
void sparrow::dynamic_bitset_base< buffer< T > * >::pop_back ( )
constexpr

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

◆ push_back()

template<std::integral T>
void sparrow::dynamic_bitset_base< buffer< T > * >::push_back ( value_type value)
constexpr

Adds a bit to the end of the bitset.

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

◆ resize()

template<std::integral T>
void sparrow::dynamic_bitset_base< buffer< T > * >::resize ( size_type n,
value_type b = false )
constexpr

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

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