sparrow 1.0.0
|
A non-owning view to a dynamic size sequence of bits stored in external memory. More...
#include <dynamic_bitset_view.hpp>
Public Types | |
using | base_type = dynamic_bitset_base<buffer_view<T>> |
Base class type providing bit operations. | |
using | storage_type = typename base_type::storage_type |
Underlying buffer view type (non-owning) | |
using | block_type = typename base_type::block_type |
Type of each storage block (same as T) | |
using | size_type = typename base_type::size_type |
Type used for sizes and indices. | |
![]() | |
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 | dynamic_bitset_view (block_type *p, size_type n) |
Constructs a bitset view from external memory. | |
constexpr | dynamic_bitset_view (block_type *p, size_type n, size_type null_count) |
Constructs a bitset view from external memory with null count tracking. | |
constexpr | ~dynamic_bitset_view ()=default |
constexpr | dynamic_bitset_view (const dynamic_bitset_view &)=default |
constexpr | dynamic_bitset_view (dynamic_bitset_view &&) noexcept=default |
constexpr dynamic_bitset_view & | operator= (const dynamic_bitset_view &)=default |
constexpr dynamic_bitset_view & | operator= (dynamic_bitset_view &&) noexcept=default |
![]() | |
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_type * | data () noexcept |
Returns a pointer to the underlying block storage. | |
constexpr const block_type * | data () 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_cvrefpointer & | buffer () const noexcept |
Returns an immutable reference to the underlying buffer. | |
constexpr storage_type_without_cvrefpointer & | buffer () 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_type * | data () noexcept |
Returns a pointer to the underlying block storage. | |
constexpr const block_type * | data () 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_cvrefpointer & | buffer () const noexcept |
Returns an immutable reference to the underlying buffer. | |
constexpr storage_type_without_cvrefpointer & | buffer () noexcept |
Returns a mutable reference to the underlying buffer. | |
storage_type | extract_storage () noexcept |
Extracts the underlying storage (move operation). | |
Additional Inherited Members | |
![]() | |
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. | |
![]() | |
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_base & | operator= (const dynamic_bitset_base &)=default |
constexpr dynamic_bitset_base & | operator= (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_base & | operator= (const dynamic_bitset_base &)=default |
constexpr dynamic_bitset_base & | operator= (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. | |
A non-owning view to a dynamic size sequence of bits stored in external memory.
This class provides a lightweight, non-owning interface to manipulate sequences of boolean values stored in external memory buffers. Unlike dynamic_bitset, this class does not manage memory allocation or deallocation - it only provides a view into existing bit data.
The view is designed for scenarios where you need to work with bit sequences that are managed elsewhere (e.g., memory-mapped files, shared memory, or buffers owned by other objects) while still benefiting from the rich bit manipulation API.
T | The integer type used to store the bits. Must satisfy std::integral. Common choices are std::uint8_t, std::uint32_t, or std::uint64_t. The choice affects memory layout and performance characteristics. |
Example usage:
Definition at line 65 of file dynamic_bitset_view.hpp.
using sparrow::dynamic_bitset_view< T >::base_type = dynamic_bitset_base<buffer_view<T>> |
Base class type providing bit operations.
Definition at line 69 of file dynamic_bitset_view.hpp.
using sparrow::dynamic_bitset_view< T >::block_type = typename base_type::block_type |
Type of each storage block (same as T)
Definition at line 71 of file dynamic_bitset_view.hpp.
using sparrow::dynamic_bitset_view< T >::size_type = typename base_type::size_type |
Type used for sizes and indices.
Definition at line 72 of file dynamic_bitset_view.hpp.
using sparrow::dynamic_bitset_view< T >::storage_type = typename base_type::storage_type |
Underlying buffer view type (non-owning)
Definition at line 70 of file dynamic_bitset_view.hpp.
|
constexpr |
Constructs a bitset view from external memory.
Creates a non-owning view over the provided memory buffer. The view will interpret the memory as a sequence of bits using the specified block type. All bits are initially assumed to be valid (non-null).
p | Pointer to the external memory buffer containing bit data |
n | The number of bits represented in the buffer |
compute_block_count(n) * sizeof(block_type)
bytes, or be nullptr if n is 0 Example:
Definition at line 156 of file dynamic_bitset_view.hpp.
|
constexpr |
Constructs a bitset view from external memory with null count tracking.
Creates a non-owning view over the provided memory buffer with explicit tracking of how many bits are null (invalid/unset). This constructor is useful when you already know the null count and want to avoid recomputing it.
p | Pointer to the external memory buffer containing bit data |
n | The number of bits represented in the buffer |
null_count | The number of bits that are set to false/null in the buffer |
compute_block_count(n) * sizeof(block_type)
bytes, or be nullptr if n is 0 Example:
Definition at line 162 of file dynamic_bitset_view.hpp.
|
constexprdefault |
|
constexprdefault |
|
constexprdefaultnoexcept |
|
constexprdefault |
|
constexprdefaultnoexcept |