SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::dynamic_bitset< bit_capacity > Class Template Reference

A constexpr bitset implementation with dynamic size at compile time. More...

#include <seqan3/utility/container/dynamic_bitset.hpp>

+ Inheritance diagram for seqan3::dynamic_bitset< bit_capacity >:

Public Types

Associated types
using value_type = bool
 Equals bool.
 
using reference = reference_proxy_type
 A proxy type that enables assignment.
 
using const_reference = bool
 Equals the value_type.
 
using iterator = detail::random_access_iterator< dynamic_bitset >
 The iterator type of this container (a random access iterator).
 
using const_iterator = detail::random_access_iterator< dynamic_bitset const >
 The const_iterator type of this container (a random access iterator).
 
using difference_type = ptrdiff_t
 A std::ptrdiff_t.
 
using size_type = detail::min_viable_uint_t< bit_capacity >
 An unsigned integer type (usually std::size_t).
 

Public Member Functions

Constructors, destructor and assignment
constexpr dynamic_bitset () noexcept=default
 Defaulted.
 
constexpr dynamic_bitset (dynamic_bitset const &) noexcept=default
 Defaulted.
 
constexpr dynamic_bitset (dynamic_bitset &&) noexcept=default
 Defaulted.
 
constexpr dynamic_bitsetoperator= (dynamic_bitset const &) noexcept=default
 Defaulted.
 
constexpr dynamic_bitsetoperator= (dynamic_bitset &&) noexcept=default
 Defaulted.
 
 ~dynamic_bitset () noexcept=default
 Defaulted.
 
constexpr dynamic_bitset (uint64_t const value)
 Construct from an uint64_t.
 
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr dynamic_bitset (begin_it_type begin_it, end_it_type end_it) noexcept
 Construct from two iterators.
 
template<std::ranges::input_range other_range_t>
requires (!std::same_as<std::remove_cvref_t<other_range_t>, dynamic_bitset>)
constexpr dynamic_bitset (other_range_t &&range) noexcept
 Construct from a different range.
 
constexpr dynamic_bitset (size_type const n, value_type const value) noexcept
 Construct with n times value.
 
constexpr dynamic_bitsetoperator= (std::initializer_list< value_type > const ilist) noexcept
 Assign from std::initializer_list.
 
template<size_t N>
constexpr dynamic_bitset (char const (&lit)[N])
 Construction from literal.
 
template<size_t N>
constexpr dynamic_bitsetoperator= (char const (&lit)[N])
 Assign from literal.
 
template<size_t N>
constexpr void assign (char const (&lit)[N])
 Assign from literal.
 
constexpr void assign (std::initializer_list< value_type > const ilist) noexcept
 Assign from std::initializer_list.
 
constexpr void assign (size_type const count, value_type const value) noexcept
 Assign with count times value.
 
template<std::ranges::input_range other_range_t>
requires std::constructible_from<value_type, std::ranges::range_reference_t<other_range_t>>
constexpr void assign (other_range_t &&range) noexcept
 Assign from a different range.
 
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr void assign (begin_it_type begin_it, end_it_type end_it) noexcept
 Assign from pair of iterators.
 
Iterators
constexpr iterator begin () noexcept
 Returns the begin to the dynamic_bitset.
 
constexpr const_iterator begin () const noexcept
 Returns the begin to the dynamic_bitset.
 
constexpr const_iterator cbegin () const noexcept
 Returns the begin to the dynamic_bitset.
 
constexpr iterator end () noexcept
 Returns iterator past the end of the dynamic_bitset.
 
constexpr const_iterator end () const noexcept
 Returns iterator past the end of the dynamic_bitset.
 
constexpr const_iterator cend () const noexcept
 Returns iterator past the end of the dynamic_bitset.
 
Bit manipulation
constexpr dynamic_bitsetoperator&= (dynamic_bitset const &rhs) noexcept
 Sets the bits to the result of binary AND on corresponding pairs of bits of *this and rhs.
 
constexpr dynamic_bitsetoperator|= (dynamic_bitset const &rhs) noexcept
 Sets the bits to the result of binary OR on corresponding pairs of bits of *this and rhs.
 
constexpr dynamic_bitsetoperator^= (dynamic_bitset const &rhs) noexcept
 Sets the bits to the result of binary XOR on corresponding pairs of bits of *this and rhs.
 
constexpr dynamic_bitset operator~ () const noexcept
 Returns a temporary copy of *this with all bits flipped (binary NOT).
 
constexpr dynamic_bitsetoperator<<= (size_t const count) noexcept
 Performs binary shift left on the current object.
 
constexpr dynamic_bitsetoperator>>= (size_t const count) noexcept
 Performs binary shift right on the current object.
 
constexpr dynamic_bitset operator>> (size_t const count) const noexcept
 Performs binary shift right.
 
constexpr dynamic_bitset operator<< (size_t const count) const noexcept
 Performs binary shift left.
 
constexpr dynamic_bitsetset () noexcept
 Sets all bits to 1.
 
constexpr dynamic_bitsetset (size_t const i, bool const value=true)
 Sets the i'th bit to value.
 
constexpr dynamic_bitsetreset () noexcept
 Sets all bits to 0.
 
constexpr dynamic_bitsetreset (size_t const i)
 Sets the i'th bit to false.
 
constexpr dynamic_bitsetflip () noexcept
 Flips all bits (binary NOT).
 
constexpr dynamic_bitsetflip (size_t const i)
 Flips the i'th bit (binary NOT).
 
Element Access
constexpr bool all () const noexcept
 Checks if all bit are set.
 
constexpr bool any () const noexcept
 Checks if any bit is set.
 
constexpr bool none () const noexcept
 Checks if no bit is set.
 
constexpr size_type count () const noexcept
 Returns the number of set bits.
 
constexpr reference at (size_t const i)
 Returns the i-th element.
 
constexpr const_reference at (size_t const i) const
 Returns the i-th element.
 
constexpr const_reference test (size_t const i) const
 Returns the i-th element.
 
constexpr reference operator[] (size_t const i) noexcept
 Returns the i-th element.
 
constexpr const_reference operator[] (size_t const i) const noexcept
 Returns the i-th element.
 
constexpr reference front () noexcept
 Returns the first element.
 
constexpr const_reference front () const noexcept
 Returns the first element.
 
constexpr reference back () noexcept
 Returns the last element.
 
constexpr const_reference back () const noexcept
 Returns the last element.
 
constexpr bitfield * raw_data () noexcept
 Direct access to the underlying bit field.
 
constexpr bitfield const * raw_data () const noexcept
 Direct access to the underlying bit field.
 
Capacity
constexpr bool empty () const noexcept
 Checks whether the container is empty.
 
constexpr size_type size () const noexcept
 Returns the number of elements in the container, i.e. std::distance(begin(), end()).
 
constexpr size_type max_size () const noexcept
 Returns the maximum number of elements the container is able to hold and resolves to bit_capacity.
 
constexpr size_type capacity () const noexcept
 Returns the number of elements that the container is able to hold and resolves to bit_capacity.
 
constexpr void reserve (size_t) const noexcept
 Since the capacity is fixed on compile time, this is a no-op.
 
constexpr void shrink_to_fit () const noexcept
 Since the capacity is fixed on compile time, this is a no-op.
 
Modifiers
constexpr void clear () noexcept
 Removes all elements from the container.
 
constexpr iterator insert (const_iterator pos, value_type const value) noexcept
 Inserts value before pos in the container.
 
constexpr iterator insert (const_iterator pos, size_type const count, value_type const value) noexcept
 Inserts count copies of value before position in the container.
 
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr iterator insert (const_iterator pos, begin_it_type begin_it, end_it_type end_it) noexcept
 Inserts elements from range [begin_it, end_it) before pos in the container.
 
constexpr iterator insert (const_iterator pos, std::initializer_list< value_type > const &ilist) noexcept
 Inserts elements from initializer list before pos in the container.
 
constexpr iterator erase (const_iterator begin_it, const_iterator end_it) noexcept
 Removes specified elements from the container.
 
constexpr iterator erase (const_iterator pos) noexcept
 Removes specified elements from the container.
 
constexpr void push_back (value_type const value) noexcept
 Appends the given element value to the end of the container.
 
constexpr void pop_back () noexcept
 Removes the last element of the container.
 
constexpr void resize (size_type const count, value_type const value=false) noexcept
 Resizes the container to contain count elements.
 
constexpr void swap (dynamic_bitset &rhs) noexcept
 Swap contents with another instance.
 
constexpr void swap (dynamic_bitset &&rhs) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
Conversions
template<typename char_t = char>
std::string to_string (char_t zero=char_t{ '0'}, char_t one=char_t{ '1'}) const
 Converts the dynamic_bitset to a std::string.
 
constexpr unsigned long to_ulong () const
 Converts the dynamic_bitset to an unsigned long integer.
 
constexpr unsigned long long to_ullong () const
 Converts the dynamic_bitset to an unsigned long long integer.
 

Friends

template<size_t >
class dynamic_bitset
 Befriend other template instantiations of dynamic_bitset.
 
constexpr void swap (dynamic_bitset &lhs, dynamic_bitset &rhs) noexcept
 Swap contents with another instance.
 
Binary operators
template<size_t cap>
requires (cap <= bit_capacity)
constexpr dynamic_bitset operator& (dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
 Returns dynamic_bitset containing the result of binary AND on corresponding pairs of bits of lhs and rhs.
 
template<size_t cap>
requires (cap <= bit_capacity)
constexpr dynamic_bitset operator^ (dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
 Returns dynamic_bitset containing the result of binary XOR on corresponding pairs of bits of lhs and rhs.
 
template<size_t cap>
requires (cap <= bit_capacity)
constexpr dynamic_bitset operator| (dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
 Returns dynamic_bitset containing the result of binary OR on corresponding pairs of bits of lhs and rhs.
 
Comparison operators
template<size_t cap>
constexpr bool operator== (dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
 Performs element-wise comparison.
 
template<size_t cap>
constexpr bool operator!= (dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
 Performs element-wise comparison.
 
template<size_t cap>
constexpr bool operator< (dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
 Performs element-wise comparison.
 
template<size_t cap>
constexpr bool operator> (dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
 Performs element-wise comparison.
 
template<size_t cap>
constexpr bool operator<= (dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
 Performs element-wise comparison.
 
template<size_t cap>
constexpr bool operator>= (dynamic_bitset const &lhs, dynamic_bitset< cap > const &rhs) noexcept
 Performs element-wise comparison.
 
Input/output
std::ostreamoperator<< (std::ostream &os, dynamic_bitset const &arg)
 Formatted output for the seqan3::dynamic_bitset.
 
std::istreamoperator>> (std::istream &is, dynamic_bitset &arg)
 Formatted input for the seqan3::dynamic_bitset.
 

Detailed Description

template<size_t bit_capacity = 58>
class seqan3::dynamic_bitset< bit_capacity >

A constexpr bitset implementation with dynamic size at compile time.

Template Parameters
bit_capacityThe capacity of the dynamic bitset

This implementation of a bitset can be constructed, accessed and modified at compile time. It has a fixed capacity but a dynamic size and provides all functionality of a sequence container. Note that it also models a reservable sequence container but all associated member functions are no-op because the capacity is fixed.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"}; // Construct from string.
seqan3::dynamic_bitset const t2{0b1011'1000}; // Construct from binary literal or integer.
seqan3::debug_stream << t1 << '\n'; // Debug printing inserts separators: 1000'1100
std::cout << t2 << '\n'; // Standard printing does not: 10111000
t1 &= t2; // Assign t1 the result of a binary AND of t1 and t2.
seqan3::debug_stream << t1 << '\n'; // 1000'1000
}
A constexpr bitset implementation with dynamic size at compile time.
Definition dynamic_bitset.hpp:51
Provides seqan3::debug_stream and related types.
A constexpr bitset implementation with dynamic size at compile time.
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:37

Thread safety

This container provides no thread-safety beyond the promise given also by the STL that all calls to const member functions are safe from multiple threads (as long as no thread calls a non-const member function at the same time).

This entity is experimental and subject to change in the future. Experimental since version 3.1.

Member Typedef Documentation

◆ const_iterator

template<size_t bit_capacity = 58>
using seqan3::dynamic_bitset< bit_capacity >::const_iterator = detail::random_access_iterator<dynamic_bitset const>

The const_iterator type of this container (a random access iterator).

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ const_reference

template<size_t bit_capacity = 58>
using seqan3::dynamic_bitset< bit_capacity >::const_reference = bool

Equals the value_type.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ difference_type

template<size_t bit_capacity = 58>
using seqan3::dynamic_bitset< bit_capacity >::difference_type = ptrdiff_t

A std::ptrdiff_t.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ iterator

template<size_t bit_capacity = 58>
using seqan3::dynamic_bitset< bit_capacity >::iterator = detail::random_access_iterator<dynamic_bitset>

The iterator type of this container (a random access iterator).

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ reference

template<size_t bit_capacity = 58>
using seqan3::dynamic_bitset< bit_capacity >::reference = reference_proxy_type

A proxy type that enables assignment.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ size_type

template<size_t bit_capacity = 58>
using seqan3::dynamic_bitset< bit_capacity >::size_type = detail::min_viable_uint_t<bit_capacity>

An unsigned integer type (usually std::size_t).

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ value_type

template<size_t bit_capacity = 58>
using seqan3::dynamic_bitset< bit_capacity >::value_type = bool

Equals bool.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

Constructor & Destructor Documentation

◆ dynamic_bitset() [1/5]

template<size_t bit_capacity = 58>
constexpr seqan3::dynamic_bitset< bit_capacity >::dynamic_bitset ( uint64_t const  value)
inlineconstexpr

Construct from an uint64_t.

Parameters
[in]valueThe uint64_t to construct/assign from.
Exceptions
std::invalid_argumentif value has bits set outside of [0, 58).

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{0b1011'1000'1111}; // Use binary literal.
seqan3::dynamic_bitset t2{0b0000'1000'1111}; // Leading zeros are stripped.
seqan3::dynamic_bitset t3{832}; // Use a number.
seqan3::debug_stream << t1 << '\n'; // 1011'1000'1111
seqan3::debug_stream << t2 << '\n'; // 1000'1111
seqan3::debug_stream << t3 << '\n'; // 1101'0000'00
}

Complexity

Constant.

Exceptions

Throws std::invalid_argument value has a set bit past the 58 one, i.e. only bits in [0,58) may be set.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ dynamic_bitset() [2/5]

template<size_t bit_capacity = 58>
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr seqan3::dynamic_bitset< bit_capacity >::dynamic_bitset ( begin_it_type  begin_it,
end_it_type  end_it 
)
inlineconstexprnoexcept

Construct from two iterators.

Template Parameters
begin_it_typeMust model std::forward_iterator and value_type must be constructible from the reference type of begin_it_type.
end_it_typeMust model std::sentinel_for.
Parameters
[in]begin_itBegin of range to construct/assign from.
[in]end_itEnd of range to construct/assign from.

Complexity

Linear in the distance between begin_it and end_it.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ dynamic_bitset() [3/5]

template<size_t bit_capacity = 58>
template<std::ranges::input_range other_range_t>
requires (!std::same_as<std::remove_cvref_t<other_range_t>, dynamic_bitset>)
constexpr seqan3::dynamic_bitset< bit_capacity >::dynamic_bitset ( other_range_t &&  range)
inlineexplicitconstexprnoexcept

Construct from a different range.

Template Parameters
other_range_tThe type of range to be inserted; must satisfy std::ranges::input_range and value_type must be constructible from std::ranges::range_reference_t<other_range_t>.
Parameters
[in]rangeThe sequence to construct/assign from.

Complexity

Linear in the size of range.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1. This is a non-standard C++ extension.

◆ dynamic_bitset() [4/5]

template<size_t bit_capacity = 58>
constexpr seqan3::dynamic_bitset< bit_capacity >::dynamic_bitset ( size_type const  n,
value_type const  value 
)
inlineconstexprnoexcept

Construct with n times value.

Parameters
[in]nNumber of elements.
[in]valueThe initial value to be assigned.

Complexity

Linear in n.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ dynamic_bitset() [5/5]

template<size_t bit_capacity = 58>
template<size_t N>
constexpr seqan3::dynamic_bitset< bit_capacity >::dynamic_bitset ( char const (&)  lit[N])
inlineconstexpr

Construction from literal.

Parameters
[in]litThe literal to construct the string for. May only contain '0' and '1'.
Exceptions
std::invalid_argumentif any character is not '0' or '1'.

The char literal is expected to be null-terminated (asserted in debug-mode). If it is not, the last character will be lost when copying to the instance of dynamic_bitset.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"101110001111"}; // Use character literal.
seqan3::dynamic_bitset t2{"000010001111"}; // Leading zeros are kept.
seqan3::debug_stream << t1 << '\n'; // 1011'1000'1111
seqan3::debug_stream << t2 << '\n'; // 0000'1000'1111
}

Complexity

Linear in the size of lit.

Exceptions

Throws std::invalid_argument if any character is not '0' or '1'.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

Member Function Documentation

◆ all()

template<size_t bit_capacity = 58>
constexpr bool seqan3::dynamic_bitset< bit_capacity >::all ( ) const
inlineconstexprnoexcept

Checks if all bit are set.

Returns
true if all bits are set or the bitset is empty, false otherwise.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ any()

template<size_t bit_capacity = 58>
constexpr bool seqan3::dynamic_bitset< bit_capacity >::any ( ) const
inlineconstexprnoexcept

Checks if any bit is set.

Returns
true if any bit is set, false otherwise.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ assign() [1/5]

template<size_t bit_capacity = 58>
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr void seqan3::dynamic_bitset< bit_capacity >::assign ( begin_it_type  begin_it,
end_it_type  end_it 
)
inlineconstexprnoexcept

Assign from pair of iterators.

Template Parameters
begin_it_typeMust model std::forward_iterator and the value_type must be constructible from the reference type of begin_it_type.
end_it_typeMust model std::sentinel_for.
Parameters
[in]begin_itBegin of range to construct/assign from.
[in]end_itEnd of range to construct/assign from.

Complexity

Linear in the distance between begin_it and end_it.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ assign() [2/5]

template<size_t bit_capacity = 58>
template<size_t N>
constexpr void seqan3::dynamic_bitset< bit_capacity >::assign ( char const (&)  lit[N])
inlineconstexpr

Assign from literal.

Parameters
[in]litThe literal to assign the string from. May only contain '0' and '1'.
Exceptions
std::invalid_argumentif any character is not '0' or '1'.

The char literal is expected to be null-terminated (asserted in debug-mode). If it is not, the last character will be lost when copying to the instance of dynamic_bitset.

Complexity

Linear in the size of lit.

Exceptions

Throws std::invalid_argument if any character is not '0' or '1'.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ assign() [3/5]

template<size_t bit_capacity = 58>
template<std::ranges::input_range other_range_t>
requires std::constructible_from<value_type, std::ranges::range_reference_t<other_range_t>>
constexpr void seqan3::dynamic_bitset< bit_capacity >::assign ( other_range_t &&  range)
inlineconstexprnoexcept

Assign from a different range.

Template Parameters
other_range_tThe type of range to be inserted; must satisfy std::ranges::input_range and value_type must be constructible from std::ranges::range_reference_t<other_range_t>.
Parameters
[in]rangeThe sequences to construct/assign from.

Complexity

Linear in the size of range.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1. This is a non-standard C++ extension.

◆ assign() [4/5]

template<size_t bit_capacity = 58>
constexpr void seqan3::dynamic_bitset< bit_capacity >::assign ( size_type const  count,
value_type const  value 
)
inlineconstexprnoexcept

Assign with count times value.

Parameters
[in]countNumber of elements.
[in]valueThe initial value to be assigned.

Complexity

Linear in count.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ assign() [5/5]

template<size_t bit_capacity = 58>
constexpr void seqan3::dynamic_bitset< bit_capacity >::assign ( std::initializer_list< value_type > const  ilist)
inlineconstexprnoexcept

Assign from std::initializer_list.

Parameters
[in]ilistA std::initializer_list of value_type.

Complexity

Linear in the size of ilist.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ at() [1/2]

template<size_t bit_capacity = 58>
constexpr reference seqan3::dynamic_bitset< bit_capacity >::at ( size_t const  i)
inlineconstexpr

Returns the i-th element.

Parameters
[in]iIndex of the element to retrieve.
Exceptions
std::out_of_rangeIf you access an element behind the last.
Returns
A reference to the value at position i.

Complexity

Constant.

Exceptions

Throws std::out_of_range if i >= size().

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ at() [2/2]

template<size_t bit_capacity = 58>
constexpr const_reference seqan3::dynamic_bitset< bit_capacity >::at ( size_t const  i) const
inlineconstexpr

Returns the i-th element.

Parameters
[in]iIndex of the element to retrieve.
Exceptions
std::out_of_rangeIf you access an element behind the last.
Returns
A reference to the value at position i.

Complexity

Constant.

Exceptions

Throws std::out_of_range if i >= size().

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ back() [1/2]

template<size_t bit_capacity = 58>
constexpr const_reference seqan3::dynamic_bitset< bit_capacity >::back ( ) const
inlineconstexprnoexcept

Returns the last element.

Returns
A reference to the value at the last position.

Calling back() on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ back() [2/2]

template<size_t bit_capacity = 58>
constexpr reference seqan3::dynamic_bitset< bit_capacity >::back ( )
inlineconstexprnoexcept

Returns the last element.

Returns
A reference to the value at the last position.

Calling back() on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ begin() [1/2]

template<size_t bit_capacity = 58>
constexpr const_iterator seqan3::dynamic_bitset< bit_capacity >::begin ( ) const
inlineconstexprnoexcept

Returns the begin to the dynamic_bitset.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{0b1011'1000'1111};
// begin() refers to the rightmost position.
for (auto it = t1.begin(); it != t1.end(); ++it)
seqan3::debug_stream << *it; // 1111'0001'1101
}

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ begin() [2/2]

template<size_t bit_capacity = 58>
constexpr iterator seqan3::dynamic_bitset< bit_capacity >::begin ( )
inlineconstexprnoexcept

Returns the begin to the dynamic_bitset.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{0b1011'1000'1111};
// begin() refers to the rightmost position.
for (auto it = t1.begin(); it != t1.end(); ++it)
seqan3::debug_stream << *it; // 1111'0001'1101
}

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ capacity()

template<size_t bit_capacity = 58>
constexpr size_type seqan3::dynamic_bitset< bit_capacity >::capacity ( ) const
inlineconstexprnoexcept

Returns the number of elements that the container is able to hold and resolves to bit_capacity.

Returns
The capacity of the currently allocated storage.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ cbegin()

template<size_t bit_capacity = 58>
constexpr const_iterator seqan3::dynamic_bitset< bit_capacity >::cbegin ( ) const
inlineconstexprnoexcept

Returns the begin to the dynamic_bitset.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{0b1011'1000'1111};
// begin() refers to the rightmost position.
for (auto it = t1.begin(); it != t1.end(); ++it)
seqan3::debug_stream << *it; // 1111'0001'1101
}

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ cend()

template<size_t bit_capacity = 58>
constexpr const_iterator seqan3::dynamic_bitset< bit_capacity >::cend ( ) const
inlineconstexprnoexcept

Returns iterator past the end of the dynamic_bitset.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{0b1011'1000'1111};
// begin() refers to the rightmost position.
for (auto it = t1.begin(); it != t1.end(); ++it)
seqan3::debug_stream << *it; // 1111'0001'1101
}

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ clear()

template<size_t bit_capacity = 58>
constexpr void seqan3::dynamic_bitset< bit_capacity >::clear ( )
inlineconstexprnoexcept

Removes all elements from the container.

Attention
In contrast to reset(), this method also sets the size to 0.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ count()

template<size_t bit_capacity = 58>
constexpr size_type seqan3::dynamic_bitset< bit_capacity >::count ( ) const
inlineconstexprnoexcept

Returns the number of set bits.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ empty()

template<size_t bit_capacity = 58>
constexpr bool seqan3::dynamic_bitset< bit_capacity >::empty ( ) const
inlineconstexprnoexcept

Checks whether the container is empty.

Returns
true if the container is empty, false otherwise.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ end() [1/2]

template<size_t bit_capacity = 58>
constexpr const_iterator seqan3::dynamic_bitset< bit_capacity >::end ( ) const
inlineconstexprnoexcept

Returns iterator past the end of the dynamic_bitset.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{0b1011'1000'1111};
// begin() refers to the rightmost position.
for (auto it = t1.begin(); it != t1.end(); ++it)
seqan3::debug_stream << *it; // 1111'0001'1101
}

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ end() [2/2]

template<size_t bit_capacity = 58>
constexpr iterator seqan3::dynamic_bitset< bit_capacity >::end ( )
inlineconstexprnoexcept

Returns iterator past the end of the dynamic_bitset.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{0b1011'1000'1111};
// begin() refers to the rightmost position.
for (auto it = t1.begin(); it != t1.end(); ++it)
seqan3::debug_stream << *it; // 1111'0001'1101
}

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ erase() [1/2]

template<size_t bit_capacity = 58>
constexpr iterator seqan3::dynamic_bitset< bit_capacity >::erase ( const_iterator  begin_it,
const_iterator  end_it 
)
inlineconstexprnoexcept

Removes specified elements from the container.

Parameters
[in]begin_itBegin of range to erase.
[in]end_itBehind the end of range to erase.
Returns
Iterator following the last element removed. If the iterator pos refers to the last element, the end() iterator is returned.

Invalidates iterators and references at or after the point of the erase, including the end() iterator.

The iterator begin_it does not need to be dereferenceable if begin_it==end_it: erasing an empty range is a no-op.

Complexity

Linear in size().

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ erase() [2/2]

template<size_t bit_capacity = 58>
constexpr iterator seqan3::dynamic_bitset< bit_capacity >::erase ( const_iterator  pos)
inlineconstexprnoexcept

Removes specified elements from the container.

Parameters
[in]posRemove the element at pos.
Returns
Iterator following the last element removed. If the iterator pos refers to the last element, the end() iterator is returned.

Invalidates iterators and references at or after the point of the erase, including the end() iterator.

The iterator pos must be valid and dereferenceable. Thus the end() iterator (which is valid, but is not dereferencable) cannot be used as a value for pos.

Complexity

Linear in size().

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ flip() [1/2]

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::flip ( )
inlineconstexprnoexcept

Flips all bits (binary NOT).

Returns
*this

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1.flip();
seqan3::debug_stream << t1 << '\n'; // 0111'0011
}
constexpr dynamic_bitset & flip() noexcept
Flips all bits (binary NOT).
Definition dynamic_bitset.hpp:962

Exception

No-throw guarantee.

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ flip() [2/2]

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::flip ( size_t const  i)
inlineconstexpr

Flips the i'th bit (binary NOT).

Parameters
[in]iIndex of the bit to flip.
Exceptions
std::out_of_rangeif you access an element behind the last.
Returns
*this

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1.flip(0);
t1.flip(3);
seqan3::debug_stream << t1 << '\n'; // 1000'0101
}

Exception

Throws std::out_of_range if i >= size().

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ front() [1/2]

template<size_t bit_capacity = 58>
constexpr const_reference seqan3::dynamic_bitset< bit_capacity >::front ( ) const
inlineconstexprnoexcept

Returns the first element.

Returns
A reference to the value at the first position.

Calling front() on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ front() [2/2]

template<size_t bit_capacity = 58>
constexpr reference seqan3::dynamic_bitset< bit_capacity >::front ( )
inlineconstexprnoexcept

Returns the first element.

Returns
A reference to the value at the first position.

Calling front() on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ insert() [1/4]

template<size_t bit_capacity = 58>
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr iterator seqan3::dynamic_bitset< bit_capacity >::insert ( const_iterator  pos,
begin_it_type  begin_it,
end_it_type  end_it 
)
inlineconstexprnoexcept

Inserts elements from range [begin_it, end_it) before pos in the container.

Template Parameters
begin_it_typeMust model std::forward_iterator and the value_type must be constructible from the reference type of begin_it_type.
end_it_typeMust model std::sentinel_for.
Parameters
[in]posIterator before which the content will be inserted. pos may be the end() iterator.
[in]begin_itBegin of range to construct/assign from.
[in]end_itEnd of range to construct/assign from.
Returns
Iterator pointing to the first element inserted, or pos if begin_it==end_it.

The behaviour is undefined if begin_it and end_it are iterators into *this or if, given the size n of the range represented by [begin_t, end_it), size() + n > capacity().

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ insert() [2/4]

template<size_t bit_capacity = 58>
constexpr iterator seqan3::dynamic_bitset< bit_capacity >::insert ( const_iterator  pos,
size_type const  count,
value_type const  value 
)
inlineconstexprnoexcept

Inserts count copies of value before position in the container.

Parameters
[in]posIterator before which the content will be inserted. pos may be the end() iterator.
[in]countNumber of copies.
[in]valueElement value to insert.
Returns
Iterator pointing to the first element inserted, or pos if count==0.

If size() + count > capacity() this function results in undefined behaviour.

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ insert() [3/4]

template<size_t bit_capacity = 58>
constexpr iterator seqan3::dynamic_bitset< bit_capacity >::insert ( const_iterator  pos,
std::initializer_list< value_type > const &  ilist 
)
inlineconstexprnoexcept

Inserts elements from initializer list before pos in the container.

Parameters
[in]posIterator before which the content will be inserted. pos may be the end() iterator.
[in]ilistInitializer list with values to insert.
Returns
Iterator pointing to the first element inserted, or pos if ilist is empty.

Given the size n of ilist, this function results in undefined behaviour if size() + n > capacity().

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ insert() [4/4]

template<size_t bit_capacity = 58>
constexpr iterator seqan3::dynamic_bitset< bit_capacity >::insert ( const_iterator  pos,
value_type const  value 
)
inlineconstexprnoexcept

Inserts value before pos in the container.

Parameters
[in]posIterator before which the content will be inserted. pos may be the end() iterator.
[in]valueElement value to insert.
Returns
Iterator pointing to the inserted value.

Inserting a value although the maximum capacity is reached is undefined behaviour.

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ max_size()

template<size_t bit_capacity = 58>
constexpr size_type seqan3::dynamic_bitset< bit_capacity >::max_size ( ) const
inlineconstexprnoexcept

Returns the maximum number of elements the container is able to hold and resolves to bit_capacity.

Returns
The number of elements in the container.

This value typically reflects the theoretical limit on the size of the container. At runtime, the size of the container may be limited to a value smaller than max_size() by the amount of RAM available.

For the dynamic_bitset holds: max_size() = capacity().

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ none()

template<size_t bit_capacity = 58>
constexpr bool seqan3::dynamic_bitset< bit_capacity >::none ( ) const
inlineconstexprnoexcept

Checks if no bit is set.

Returns
true if no bit is set, false otherwise.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator&=()

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::operator&= ( dynamic_bitset< bit_capacity > const &  rhs)
inlineconstexprnoexcept

Sets the bits to the result of binary AND on corresponding pairs of bits of *this and rhs.

Parameters
[in]rhsdynamic_bitset to perform binary AND with.
Returns
*this
Attention
Both dynamic_bitsets must have the same size. In debug mode an assertion checks this constraint.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"};
seqan3::dynamic_bitset const t2{0b1011'1000};
t1 &= t2;
seqan3::debug_stream << t1 << '\n'; // 1000'1000
}

Exception

No-throw guarantee.

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator<<()

template<size_t bit_capacity = 58>
constexpr dynamic_bitset seqan3::dynamic_bitset< bit_capacity >::operator<< ( size_t const  count) const
inlineconstexprnoexcept

Performs binary shift left.

Parameters
[in]countAmount to shift to the left.
Returns
Copy of *this with bits shifted count to the left.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset const t1{"10001100"};
seqan3::dynamic_bitset t2 = t1 << 3;
seqan3::debug_stream << t2 << '\n'; // 0110'0000
}

Exception

No-throw guarantee.

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator<<=()

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::operator<<= ( size_t const  count)
inlineconstexprnoexcept

Performs binary shift left on the current object.

Parameters
[in]countAmount to shift to the left.
Returns
*this

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1 <<= 3;
seqan3::debug_stream << t1 << '\n'; // 0110'0000
}

Exception

No-throw guarantee.

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator=() [1/2]

template<size_t bit_capacity = 58>
template<size_t N>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::operator= ( char const (&)  lit[N])
inlineconstexpr

Assign from literal.

Parameters
[in]litThe literal to assign the string from. May only contain '0' and '1'.
Exceptions
std::invalid_argumentif any character is not '0' or '1'.

The char literal is expected to be null-terminated (asserted in debug-mode). If it is not, the last character will be lost when copying to the instance of dynamic_bitset.

Complexity

Linear in the size of lit.

Exceptions

Throws std::invalid_argument if any character is not '0' or '1'.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator=() [2/2]

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::operator= ( std::initializer_list< value_type > const  ilist)
inlineconstexprnoexcept

Assign from std::initializer_list.

Parameters
[in]ilistA std::initializer_list of value_type.

Complexity

Linear in the size of ilist.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator>>()

template<size_t bit_capacity = 58>
constexpr dynamic_bitset seqan3::dynamic_bitset< bit_capacity >::operator>> ( size_t const  count) const
inlineconstexprnoexcept

Performs binary shift right.

Parameters
[in]countAmount to shift to the right.
Returns
Copy of *this with bits shifted count to the right.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset const t1{"10001100"};
seqan3::dynamic_bitset t2 = t1 >> 3;
seqan3::debug_stream << t2 << '\n'; // 0001'0001
}

Exception

No-throw guarantee.

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator>>=()

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::operator>>= ( size_t const  count)
inlineconstexprnoexcept

Performs binary shift right on the current object.

Parameters
[in]countAmount to shift to the right.
Returns
*this

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1 >>= 3;
seqan3::debug_stream << t1 << '\n'; // 0001'0001
}

Exception

No-throw guarantee.

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator[]() [1/2]

template<size_t bit_capacity = 58>
constexpr const_reference seqan3::dynamic_bitset< bit_capacity >::operator[] ( size_t const  i) const
inlineconstexprnoexcept

Returns the i-th element.

Parameters
[in]iThe element to retrieve.
Returns
A reference to the value at position i.

Accessing an element behind the last causes undefined behaviour. In debug mode an assertion checks the size of the container.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{0b1011'1000'1111};
// Positions are 0-based and start at the rightmost bit.
for (size_t i = 0; i < t1.size(); ++i)
seqan3::debug_stream << t1[i]; // 1111'0001'1101
}

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator[]() [2/2]

template<size_t bit_capacity = 58>
constexpr reference seqan3::dynamic_bitset< bit_capacity >::operator[] ( size_t const  i)
inlineconstexprnoexcept

Returns the i-th element.

Parameters
[in]iThe element to retrieve.
Returns
A reference to the value at position i.

Accessing an element behind the last causes undefined behaviour. In debug mode an assertion checks the size of the container.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{0b1011'1000'1111};
// Positions are 0-based and start at the rightmost bit.
for (size_t i = 0; i < t1.size(); ++i)
seqan3::debug_stream << t1[i]; // 1111'0001'1101
}

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator^=()

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::operator^= ( dynamic_bitset< bit_capacity > const &  rhs)
inlineconstexprnoexcept

Sets the bits to the result of binary XOR on corresponding pairs of bits of *this and rhs.

Parameters
[in]rhsdynamic_bitset to perform binary XOR with.
Returns
*this
Attention
Both dynamic_bitsets must have the same size. In debug mode an assertion checks this constraint.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"};
seqan3::dynamic_bitset const t2{0b1011'1000};
t1 ^= t2;
seqan3::debug_stream << t1 << '\n'; // 0011'0100
}

Exception

No-throw guarantee.

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator|=()

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::operator|= ( dynamic_bitset< bit_capacity > const &  rhs)
inlineconstexprnoexcept

Sets the bits to the result of binary OR on corresponding pairs of bits of *this and rhs.

Parameters
[in]rhsdynamic_bitset to perform binary OR with.
Returns
*this
Attention
Both dynamic_bitsets must have the same size. In debug mode an assertion checks this constraint.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"};
seqan3::dynamic_bitset const t2{0b1011'1000};
t1 |= t2;
seqan3::debug_stream << t1 << '\n'; // 1011'1100
}

Exception

No-throw guarantee.

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator~()

template<size_t bit_capacity = 58>
constexpr dynamic_bitset seqan3::dynamic_bitset< bit_capacity >::operator~ ( ) const
inlineconstexprnoexcept

Returns a temporary copy of *this with all bits flipped (binary NOT).

Returns
Copy of *this with all bits flipped.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset const t1{"10001100"};
seqan3::debug_stream << t2 << '\n'; // 0111'0011
}

Exception

No-throw guarantee.

Thread-safety

Thread safe.

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ pop_back()

template<size_t bit_capacity = 58>
constexpr void seqan3::dynamic_bitset< bit_capacity >::pop_back ( )
inlineconstexprnoexcept

Removes the last element of the container.

Calling pop_back() on an empty container is undefined. In debug mode an assertion will be thrown.

No iterators or references except for back() and end() are invalidated.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ push_back()

template<size_t bit_capacity = 58>
constexpr void seqan3::dynamic_bitset< bit_capacity >::push_back ( value_type const  value)
inlineconstexprnoexcept

Appends the given element value to the end of the container.

Parameters
[in]valueThe value to append.

If the new size() is greater than capacity() this is undefined behaviour.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ raw_data() [1/2]

template<size_t bit_capacity = 58>
constexpr bitfield const * seqan3::dynamic_bitset< bit_capacity >::raw_data ( ) const
inlineconstexprnoexcept

Direct access to the underlying bit field.

This entity is not part of the SeqAn API. Do not rely on it in your applications. The exact representation of the data is implementation defined.

◆ raw_data() [2/2]

template<size_t bit_capacity = 58>
constexpr bitfield * seqan3::dynamic_bitset< bit_capacity >::raw_data ( )
inlineconstexprnoexcept

Direct access to the underlying bit field.

This entity is not part of the SeqAn API. Do not rely on it in your applications. The exact representation of the data is implementation defined.

◆ reserve()

template<size_t bit_capacity = 58>
constexpr void seqan3::dynamic_bitset< bit_capacity >::reserve ( size_t  ) const
inlineconstexprnoexcept

Since the capacity is fixed on compile time, this is a no-op.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ reset() [1/2]

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::reset ( )
inlineconstexprnoexcept

Sets all bits to 0.

Returns
*this
Attention
In contrast to clear(), this method does not modify the size.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1.reset();
seqan3::debug_stream << t1 << '\n'; // 0000'0000
}
constexpr dynamic_bitset & reset() noexcept
Sets all bits to 0.
Definition dynamic_bitset.hpp:910

Exception

No-throw guarantee.

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ reset() [2/2]

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::reset ( size_t const  i)
inlineconstexpr

Sets the i'th bit to false.

Parameters
[in]iIndex of the bit to reset.
Exceptions
std::out_of_rangeif you access an element behind the last.
Returns
*this

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1.reset(2);
t1.reset(3);
seqan3::debug_stream << t1 << '\n'; // 1000'0000
}

Exception

Throws std::out_of_range if i >= size().

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ resize()

template<size_t bit_capacity = 58>
constexpr void seqan3::dynamic_bitset< bit_capacity >::resize ( size_type const  count,
value_type const  value = false 
)
inlineconstexprnoexcept

Resizes the container to contain count elements.

Parameters
[in]countThe new size.
[in]valueAppend copies of value when resizing, default = false.

If count is greater than capacity() this is undefined behaviour. If the dynamic_bitset is enlarged, bits in [0, size()) stay the same and bits in [size(), count) are set to value. If the dynamic_bitset is shrunk, bits in [0, count) stay the same and bits in [count, size()) are set to 0.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
t1.resize(8); // Enlarge to 8.
seqan3::debug_stream << t1 << '\n'; // 0000'1100
t1.resize(5); // Shrink to 5, last three bits (5, 6, 7) are set to false.
seqan3::debug_stream << t1 << '\n'; // 0110'0
t1.resize(10, true); // Enlarge to 10 and set new bits to true.
seqan3::debug_stream << t1 << '\n'; // 1111'1011'00
}
constexpr void resize(size_type const count, value_type const value=false) noexcept
Resizes the container to contain count elements.
Definition dynamic_bitset.hpp:1586

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ set() [1/2]

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::set ( )
inlineconstexprnoexcept

Sets all bits to 1.

Returns
*this

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1.set();
seqan3::debug_stream << t1 << '\n'; // 1111'1111
}
constexpr dynamic_bitset & set() noexcept
Sets all bits to 1.
Definition dynamic_bitset.hpp:854

Exception

No-throw guarantee.

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ set() [2/2]

template<size_t bit_capacity = 58>
constexpr dynamic_bitset & seqan3::dynamic_bitset< bit_capacity >::set ( size_t const  i,
bool const  value = true 
)
inlineconstexpr

Sets the i'th bit to value.

Parameters
[in]iIndex of the bit to set.
[in]valueValue to set. Default true.
Exceptions
std::out_of_rangeif you access an element behind the last.
Returns
*this

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1.set(0);
t1.set(2, false);
seqan3::debug_stream << t1 << '\n'; // 1000'1001
}

Exception

Throws std::out_of_range if i >= size().

Complexity

Constant.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ shrink_to_fit()

template<size_t bit_capacity = 58>
constexpr void seqan3::dynamic_bitset< bit_capacity >::shrink_to_fit ( ) const
inlineconstexprnoexcept

Since the capacity is fixed on compile time, this is a no-op.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ size()

template<size_t bit_capacity = 58>
constexpr size_type seqan3::dynamic_bitset< bit_capacity >::size ( ) const
inlineconstexprnoexcept

Returns the number of elements in the container, i.e. std::distance(begin(), end()).

Returns
The number of elements in the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ swap()

template<size_t bit_capacity = 58>
constexpr void seqan3::dynamic_bitset< bit_capacity >::swap ( dynamic_bitset< bit_capacity > &  rhs)
inlineconstexprnoexcept

Swap contents with another instance.

Parameters
[in]rhsThe other instance to swap with.

Complexity

Linear in the size of both containers.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ test()

template<size_t bit_capacity = 58>
constexpr const_reference seqan3::dynamic_bitset< bit_capacity >::test ( size_t const  i) const
inlineconstexpr

Returns the i-th element.

Parameters
[in]iIndex of the element to retrieve.
Exceptions
std::out_of_rangeIf you access an element behind the last.
Returns
A reference to the value at position i.

Complexity

Constant.

Exceptions

Throws std::out_of_range if i >= size().

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ to_string()

template<size_t bit_capacity = 58>
template<typename char_t = char>
std::string seqan3::dynamic_bitset< bit_capacity >::to_string ( char_t  zero = char_t{'0'},
char_t  one = char_t{'1'} 
) const
inline

Converts the dynamic_bitset to a std::string.

Template Parameters
char_tChar type; must model seqan3::builtin_character.
Parameters
[in]zerobuiltin_character of type char_t representing false. Default '0'.
[in]onebuiltin_character of type char_t representing true. Default '1'.
Exceptions
std::bad_allocfrom the the std::string constructor.
Returns
A std::string representing the dynamic_bitset.
Attention
This is the only function of this class that is not constexpr because std::string is not constexpr.

Complexity

Linear in size().

Exceptions

Throws std::bad_alloc from the std::string constructor.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ to_ullong()

template<size_t bit_capacity = 58>
constexpr unsigned long long seqan3::dynamic_bitset< bit_capacity >::to_ullong ( ) const
inlineconstexpr

Converts the dynamic_bitset to an unsigned long long integer.

Exceptions
std::overflow_errorif the value cannot be represented in unsigned long long.
Returns
A unsigned long long representing the dynamic_bitset.

Complexity

Constant.

Exceptions

Throws std::overflow_error if the value cannot be represented in unsigned long long.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ to_ulong()

template<size_t bit_capacity = 58>
constexpr unsigned long seqan3::dynamic_bitset< bit_capacity >::to_ulong ( ) const
inlineconstexpr

Converts the dynamic_bitset to an unsigned long integer.

Exceptions
std::overflow_errorif the value cannot be represented in unsigned long.
Returns
A unsigned long representing the dynamic_bitset.

Complexity

Constant.

Exceptions

Throws std::overflow_error if the value cannot be represented in unsigned long.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

Friends And Related Symbol Documentation

◆ operator!=

template<size_t bit_capacity = 58>
template<size_t cap>
constexpr bool operator!= ( dynamic_bitset< bit_capacity > const &  lhs,
dynamic_bitset< cap > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator&

template<size_t bit_capacity = 58>
template<size_t cap>
requires (cap <= bit_capacity)
constexpr dynamic_bitset operator& ( dynamic_bitset< bit_capacity > const &  lhs,
dynamic_bitset< cap > const &  rhs 
)
friend

Returns dynamic_bitset containing the result of binary AND on corresponding pairs of bits of lhs and rhs.

Attention
Both dynamic_bitsets must have the same size. In debug mode an assertion checks this constraint.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator<

template<size_t bit_capacity = 58>
template<size_t cap>
constexpr bool operator< ( dynamic_bitset< bit_capacity > const &  lhs,
dynamic_bitset< cap > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator<<

template<size_t bit_capacity = 58>
std::ostream & operator<< ( std::ostream os,
dynamic_bitset< bit_capacity > const &  arg 
)
friend

Formatted output for the seqan3::dynamic_bitset.

Parameters
[in,out]osThe std::basic_ostream to write to.
[in]argThe seqan3::dynamic_bitset to read from.
Returns
os.

Internally calls os << arg.to_string().

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator<=

template<size_t bit_capacity = 58>
template<size_t cap>
constexpr bool operator<= ( dynamic_bitset< bit_capacity > const &  lhs,
dynamic_bitset< cap > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator==

template<size_t bit_capacity = 58>
template<size_t cap>
constexpr bool operator== ( dynamic_bitset< bit_capacity > const &  lhs,
dynamic_bitset< cap > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator>

template<size_t bit_capacity = 58>
template<size_t cap>
constexpr bool operator> ( dynamic_bitset< bit_capacity > const &  lhs,
dynamic_bitset< cap > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator>=

template<size_t bit_capacity = 58>
template<size_t cap>
constexpr bool operator>= ( dynamic_bitset< bit_capacity > const &  lhs,
dynamic_bitset< cap > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator>>

template<size_t bit_capacity = 58>
std::istream & operator>> ( std::istream is,
dynamic_bitset< bit_capacity > &  arg 
)
friend

Formatted input for the seqan3::dynamic_bitset.

Parameters
[in,out]isThe std::basic_istream to read from.
[out]argThe seqan3::dynamic_bitset to write to.
Returns
is.

Reads at most seqan3::dynamic_bitset::max_size() characters from the stream. If a stream error occurred or no characters could be extracted the std::ios_base::failbit is set. This may throw an exception.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator^

template<size_t bit_capacity = 58>
template<size_t cap>
requires (cap <= bit_capacity)
constexpr dynamic_bitset operator^ ( dynamic_bitset< bit_capacity > const &  lhs,
dynamic_bitset< cap > const &  rhs 
)
friend

Returns dynamic_bitset containing the result of binary XOR on corresponding pairs of bits of lhs and rhs.

Attention
Both dynamic_bitsets must have the same size. In debug mode an assertion checks this constraint.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator|

template<size_t bit_capacity = 58>
template<size_t cap>
requires (cap <= bit_capacity)
constexpr dynamic_bitset operator| ( dynamic_bitset< bit_capacity > const &  lhs,
dynamic_bitset< cap > const &  rhs 
)
friend

Returns dynamic_bitset containing the result of binary OR on corresponding pairs of bits of lhs and rhs.

Attention
Both dynamic_bitsets must have the same size. In debug mode an assertion checks this constraint.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ swap

template<size_t bit_capacity = 58>
constexpr void swap ( dynamic_bitset< bit_capacity > &  lhs,
dynamic_bitset< bit_capacity > &  rhs 
)
friend

Swap contents with another instance.

Parameters
[in]lhsThe first instance.
[in]rhsThe other instance to swap with.

Complexity

Linear in the size of both containers.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.


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