A dynamic size sequence of bits with efficient storage and manipulation operations.
More...
|
template<std::ranges::input_range R, allocator A = default_allocator>
requires std::convertible_to<std::ranges::range_value_t<R>, value_type> |
| constexpr | dynamic_bitset (const R &r, const A &a=A()) |
| | Constructs a dynamic_bitset from an input range of convertible values.
|
| |
template<class A = default_allocator>
requires (not std::same_as<A, dynamic_bitset<T>> and allocator<A>) |
| constexpr | dynamic_bitset (const A &a=A()) |
| | Default constructor.
|
| |
| template<allocator A = default_allocator> |
| constexpr | dynamic_bitset (size_type n, const A &a=A()) |
| | Constructs a bitset with n bits, all initialized to false.
|
| |
| template<allocator A = default_allocator> |
| constexpr | dynamic_bitset (size_type n, value_type v, const A &a=A()) |
| | Constructs a bitset with n bits, all initialized to the specified value.
|
| |
| template<allocator A = default_allocator> |
| constexpr | dynamic_bitset (block_type *p, size_type n, const A &a=A()) |
| | Constructs a bitset using existing memory.
|
| |
| template<allocator A = default_allocator> |
| constexpr | dynamic_bitset (block_type *p, size_type n, size_type null_count, const A &a=A()) |
| | Constructs a bitset using existing memory with null count tracking.
|
| |
| constexpr | ~dynamic_bitset ()=default |
| |
| constexpr | dynamic_bitset (const dynamic_bitset &)=default |
| |
| constexpr | dynamic_bitset (dynamic_bitset &&) noexcept=default |
| |
| template<allocator A> |
| constexpr | dynamic_bitset (const dynamic_bitset &rhs, const A &a) |
| |
| template<allocator A> |
| constexpr | dynamic_bitset (dynamic_bitset &&rhs, const A &a) |
| |
| constexpr dynamic_bitset & | operator= (const dynamic_bitset &)=default |
| |
| constexpr dynamic_bitset & | operator= (dynamic_bitset &&) noexcept=default |
| |
| constexpr void | clear () noexcept |
| | Removes all bits from the bitset.
|
| |
| constexpr iterator | emplace (const_iterator pos, value_type value) |
| | < Remove all bits from the bitset
|
| |
| constexpr iterator | erase (const_iterator pos) |
| | < Emplace a bit at a specific position
|
| |
| constexpr iterator | erase (const_iterator first, const_iterator last) |
| | < Emplace a bit at a specific position
|
| |
| constexpr iterator | insert (const_iterator pos, value_type value) |
| | < Remove bits from the bitset
|
| |
| constexpr iterator | insert (const_iterator pos, size_type count, value_type value) |
| | < Remove bits from the bitset
|
| |
| constexpr iterator | insert (const_iterator pos, InputIt first, InputIt last) |
| | < Remove bits from the bitset
|
| |
| constexpr iterator | insert (const_iterator pos, std::initializer_list< value_type > ilist) |
| | < Remove bits from the bitset
|
| |
| constexpr void | pop_back () |
| | < Insert bits into the bitset
|
| |
| constexpr void | push_back (value_type value) |
| | < Remove the last bit
|
| |
| constexpr void | resize (size_type n, value_type b=false) |
| | < Add a bit to the end
|
| |
| 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).
|
| |
|
| 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.
|
| |
template<std::integral T>
class sparrow::dynamic_bitset< T >
A dynamic size sequence of bits with efficient storage and manipulation operations.
This class provides a container for storing and manipulating sequences of boolean values using an underlying integer type for efficient bit-level operations. The bitset can grow and shrink dynamically, similar to std::vector, while providing specialized bit manipulation methods.
- Template Parameters
-
| 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. |
- Note
- The class inherits from dynamic_bitset_base which provides the core bit manipulation functionality. This class adds constructors and manages the underlying buffer storage.
Example usage:
std::vector<bool> values = {true, false, true, false};
bits.set(5, true);
bool bit_value = bits.test(5);
A dynamic size sequence of bits with efficient storage and manipulation operations.
constexpr dynamic_bitset(const R &r, const A &a=A())
Constructs a dynamic_bitset from an input range of convertible values.
Definition at line 56 of file dynamic_bitset.hpp.