|
sparrow 2.2.1
C++20 idiomatic APIs for the Apache Arrow Columnar Format
|
Base class providing core functionality for dynamic bitset implementations. More...
#include <dynamic_bitset_base.hpp>
Public Types | |
| using | self_type = dynamic_bitset_base<B, NCP> |
| This class type. | |
| using | null_count_policy_type = NCP |
| Null count tracking policy 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 void | set_size (size_type new_size) noexcept |
| constexpr size_type | offset () const noexcept |
| Returns the bit offset within the buffer. | |
| constexpr void | set_offset (size_type offset) noexcept |
| Sets the bit offset within the buffer. | |
| 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). | |
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 offset) |
| Constructs a bitset with the given storage, size, and null count. | |
| constexpr | dynamic_bitset_base (storage_type buffer, size_type size, size_type offset, size_type null_count) |
| Constructs a bitset with the given storage, size, offset, 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. | |
| 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. | |
Protected Member Functions inherited from sparrow::tracking_null_count< SizeType > | |
| constexpr | tracking_null_count () noexcept=default |
| constexpr | tracking_null_count (size_type count) noexcept |
| template<std::integral BlockType> | |
| void | initialize_null_count (const BlockType *data, size_type bit_size, size_type block_count, size_type offset=0) noexcept |
| Initializes the null count by counting bits in the buffer. | |
| constexpr size_type | null_count () const noexcept |
| constexpr void | set_null_count (size_type count) noexcept |
| template<std::integral BlockType> | |
| void | recompute_null_count (const BlockType *data, size_type bit_size, size_type block_count, size_type offset=0) noexcept |
| Recomputes the null count from the buffer. | |
| constexpr void | update_null_count (bool old_value, bool new_value) noexcept |
| constexpr void | swap_null_count (tracking_null_count &other) noexcept |
| constexpr void | clear_null_count () noexcept |
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. | |
Additional Inherited Members | |
Protected Types inherited from sparrow::tracking_null_count< SizeType > | |
| using | size_type = SizeType |
Static Protected Attributes inherited from sparrow::tracking_null_count< SizeType > | |
| static constexpr bool | track_null_count = true |
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.
| B | The 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. |
Example usage through derived classes:
Definition at line 68 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::block_type = typename storage_type_without_cvrefpointer::value_type |
Type of each storage block (integral type)
Definition at line 77 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::const_iterator = bitset_iterator<self_type, true> |
Immutable iterator type.
Definition at line 88 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::const_reference = bool |
Immutable reference to a bit (plain bool)
Definition at line 81 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::difference_type = typename storage_type_without_cvrefpointer::difference_type |
Type for iterator differences.
Definition at line 84 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::iterator = bitset_iterator<self_type, false> |
Mutable iterator type.
Definition at line 87 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::null_count_policy_type = NCP |
Null count tracking policy type.
Definition at line 73 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::reference = bitset_reference<self_type> |
Mutable reference to a bit.
Definition at line 80 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::self_type = dynamic_bitset_base<B, NCP> |
This class type.
Definition at line 72 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::size_type = typename storage_type_without_cvrefpointer::size_type |
Type for sizes and indices.
Definition at line 82 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::storage_type = B |
Underlying storage container type.
Definition at line 74 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::storage_type_without_cvrefpointer |
Storage type without CV/ref/pointer qualifiers.
Definition at line 75 of file dynamic_bitset_base.hpp.
| using sparrow::dynamic_bitset_base< B, NCP >::value_type = bool |
Type of individual bit values.
Definition at line 79 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Constructs a bitset with the given storage and size.
| buffer | The storage buffer to use |
| size | The number of bits in the bitset |
Definition at line 876 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Constructs a bitset with the given storage, size, and null count.
| buffer | The storage buffer to use |
| size | The number of bits in the bitset |
| offset | The offset in bits from the start of the buffer |
Definition at line 886 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Constructs a bitset with the given storage, size, offset, and null count.
| buffer | The storage buffer to use |
| size | The number of bits in the bitset |
| offset | The offset in bits from the start of the buffer |
| null_count | The number of unset bits |
Definition at line 896 of file dynamic_bitset_base.hpp.
|
constexprprotecteddefault |
|
constexprprotecteddefault |
|
constexprprotecteddefaultnoexcept |
|
nodiscardconstexpr |
Accesses a bit with bounds checking.
| pos | The position of the bit to access |
| std::out_of_range | if pos >= size() |
Definition at line 808 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Accesses a bit with bounds checking.
| pos | The position of the bit to access |
| std::out_of_range | if pos >= size() |
Definition at line 822 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Accesses the last bit.
Definition at line 856 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Accesses the last bit.
Definition at line 864 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Returns a mutable iterator to the first bit.
Definition at line 766 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Returns an immutable iterator to the first bit.
Definition at line 780 of file dynamic_bitset_base.hpp.
|
nodiscardconstexprnoexcept |
Returns the number of storage blocks.
Definition at line 748 of file dynamic_bitset_base.hpp.
|
inlinenodiscardconstexprnoexcept |
Returns an immutable reference to the underlying buffer.
Definition at line 309 of file dynamic_bitset_base.hpp.
|
inlinenodiscardconstexprnoexcept |
Returns a mutable reference to the underlying buffer.
Definition at line 326 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Returns an immutable iterator to the first bit.
Definition at line 794 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Returns an immutable iterator past the last bit.
Definition at line 801 of file dynamic_bitset_base.hpp.
|
constexprprotectednoexcept |
Removes all bits from the bitset.
Definition at line 1023 of file dynamic_bitset_base.hpp.
|
staticnodiscardconstexprnoexcept |
Computes the number of blocks needed to store the specified number of bits.
| bits_count | The number of bits to store |
Definition at line 912 of file dynamic_bitset_base.hpp.
|
nodiscardconstexprnoexcept |
Returns a pointer to the underlying block storage.
Definition at line 741 of file dynamic_bitset_base.hpp.
|
nodiscardconstexprnoexcept |
Returns a pointer to the underlying block storage.
Definition at line 727 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Constructs a bit in-place at the specified position.
| pos | Iterator pointing to the insertion position |
| value | The value of the bit to emplace |
Definition at line 1127 of file dynamic_bitset_base.hpp.
|
nodiscardconstexprnoexcept |
Checks if the bitset contains no bits.
Definition at line 604 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Returns a mutable iterator past the last bit.
Definition at line 773 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Returns an immutable iterator past the last bit.
Definition at line 787 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Removes bits in the specified range.
| first | Iterator pointing to the first bit to remove |
| last | Iterator pointing past the last bit to remove |
Definition at line 1145 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Removes a single bit at the specified position.
| pos | Iterator pointing to the bit to remove |
Definition at line 1134 of file dynamic_bitset_base.hpp.
|
inlinenodiscardnoexcept |
Extracts the underlying storage (move operation).
Definition at line 354 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Accesses the first bit.
Definition at line 836 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Accesses the first bit.
Definition at line 844 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Inserts bits from an iterator range at the specified position.
| InputIt | Input iterator type |
| pos | Iterator pointing to the insertion position |
| first | Iterator pointing to the first bit to insert |
| last | Iterator pointing past the last bit to insert |
Definition at line 1078 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Inserts multiple bits with the same value at the specified position.
| pos | Iterator pointing to the insertion position |
| count | The number of bits to insert |
| value | The value of the bits to insert |
Definition at line 1041 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Inserts bits from an initializer list at the specified position.
| pos | Iterator pointing to the insertion position |
| ilist | Initializer list containing the bits to insert |
|
constexprprotected |
Inserts a single bit at the specified position.
| pos | Iterator pointing to the insertion position |
| value | The value of the bit to insert |
Definition at line 1033 of file dynamic_bitset_base.hpp.
|
nodiscardconstexprnoexcept |
Returns the number of bits set to false (null/invalid).
Definition at line 625 of file dynamic_bitset_base.hpp.
|
nodiscardconstexprnoexcept |
Returns the bit offset within the buffer.
Definition at line 611 of file dynamic_bitset_base.hpp.
|
constexprprotecteddefault |
|
constexprprotecteddefaultnoexcept |
|
nodiscardconstexpr |
Accesses a bit without bounds checking.
| i | The position of the bit to access |
Definition at line 633 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Accesses a bit without bounds checking.
| i | The position of the bit to access |
Definition at line 641 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Removes the last bit from the bitset.
Definition at line 1193 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Adds a bit to the end of the bitset.
| value | The value of the bit to add |
Definition at line 1186 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Resizes the bitset to contain n bits.
| n | The new size in bits |
| b | The value to initialize new bits with (default false) |
Definition at line 963 of file dynamic_bitset_base.hpp.
|
constexpr |
Sets the value of a bit at the specified position.
| pos | The position of the bit to set |
| value | The value to set (true or false) |
| std::runtime_error | if trying to set false on a non-resizable null buffer |
Definition at line 670 of file dynamic_bitset_base.hpp.
|
constexprnoexcept |
Sets the bit offset within the buffer.
| offset | The new offset in bits from the start of the buffer |
Definition at line 618 of file dynamic_bitset_base.hpp.
|
constexprnoexcept |
Definition at line 597 of file dynamic_bitset_base.hpp.
|
nodiscardconstexprnoexcept |
Returns the number of bits in the bitset.
Definition at line 590 of file dynamic_bitset_base.hpp.
|
constexprnoexcept |
Swaps the contents with another bitset.
| rhs | The other bitset to swap with |
Definition at line 755 of file dynamic_bitset_base.hpp.
|
nodiscardconstexpr |
Tests the value of a bit at the specified position.
| pos | The position of the bit to test |
Definition at line 648 of file dynamic_bitset_base.hpp.
|
constexprprotected |
Clears any unused bits in the last storage block.
Definition at line 948 of file dynamic_bitset_base.hpp.
|
friend |
Mutable iterator needs access to internals.
Definition at line 581 of file dynamic_bitset_base.hpp.
|
friend |
Const iterator needs access to internals.
Definition at line 581 of file dynamic_bitset_base.hpp.
|
friend |
Bit reference needs access to internals.
Definition at line 581 of file dynamic_bitset_base.hpp.