SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
seqan3::shape Class Reference

A class that defines which positions of a pattern to hash. More...

#include <seqan3/search/kmer_index/shape.hpp>

+ Inheritance diagram for seqan3::shape:

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 shape () noexcept=default
 Defaulted.
 
constexpr shape (shape const &) noexcept=default
 Defaulted.
 
constexpr shape (shape &&) noexcept=default
 Defaulted.
 
constexpr shapeoperator= (shape const &) noexcept=default
 Defaulted.
 
constexpr shapeoperator= (shape &&) noexcept=default
 Defaulted.
 
 ~shape () noexcept=default
 Defaulted.
 
constexpr shape (ungapped k) noexcept
 Construct an ungapped shape from a given size. More...
 
constexpr shape (bin_literal const literal) noexcept
 Construct from a given seqan3::bin_literal. More...
 
Constructors, destructor and assignment
constexpr void assign (char const(&lit)[N])
 Assign from literal. More...
 
constexpr void assign (std::initializer_list< value_type > const ilist) noexcept
 Assign from std::initializer_list. More...
 
constexpr void assign (size_type const count, value_type const value) noexcept
 Assign with count times value. More...
 
constexpr void assign (other_range_t &&range) noexcept
 Assign from a different range. More...
 
constexpr void assign (begin_it_type begin_it, end_it_type end_it) noexcept
 Assign from pair of iterators. More...
 
Iterators
constexpr iterator begin () noexcept
 Returns the begin to the dynamic_bitset. More...
 
constexpr const_iterator begin () const noexcept
 Returns the begin to the dynamic_bitset. More...
 
constexpr const_iterator cbegin () const noexcept
 Returns the begin to the dynamic_bitset. More...
 
constexpr iterator end () noexcept
 Returns iterator past the end of the dynamic_bitset. More...
 
constexpr const_iterator end () const noexcept
 Returns iterator past the end of the dynamic_bitset. More...
 
constexpr const_iterator cend () const noexcept
 Returns iterator past the end of the dynamic_bitset. More...
 
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. More...
 
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. More...
 
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. More...
 
constexpr dynamic_bitset operator~ () const noexcept
 Returns a temporary copy of *this with all bits flipped (binary NOT). More...
 
constexpr dynamic_bitsetoperator<<= (size_t const count) noexcept
 Performs binary shift left on the current object. More...
 
constexpr dynamic_bitsetoperator>>= (size_t const count) noexcept
 Performs binary shift right on the current object. More...
 
constexpr dynamic_bitset operator>> (size_t const count) const noexcept
 Performs binary shift right. More...
 
constexpr dynamic_bitset operator<< (size_t const count) const noexcept
 Performs binary shift left. More...
 
constexpr dynamic_bitsetset () noexcept
 Sets all bits to 1. More...
 
constexpr dynamic_bitsetset (size_t const i, bool const value=true)
 Sets the i'th bit to value. More...
 
constexpr dynamic_bitsetreset () noexcept
 Sets all bits to 0. More...
 
constexpr dynamic_bitsetreset (size_t const i)
 Sets the i'th bit to false. More...
 
constexpr dynamic_bitsetflip () noexcept
 Flips all bits (binary NOT). More...
 
constexpr dynamic_bitsetflip (size_t const i)
 Flips the i'th bit (binary NOT). More...
 
Element Access
constexpr bool all () const noexcept
 Checks if all bit are set. More...
 
constexpr bool any () const noexcept
 Checks if any bit is set. More...
 
constexpr bool none () const noexcept
 Checks if no bit is set. More...
 
constexpr size_type count () const noexcept
 Returns the number of set bits.
 
constexpr reference at (size_t const i)
 Returns the i-th element. More...
 
constexpr const_reference at (size_t const i) const
 Returns the i-th element. More...
 
constexpr const_reference test (size_t const i) const
 Returns the i-th element. More...
 
constexpr reference operator[] (size_t const i) noexcept
 Returns the i-th element. More...
 
constexpr const_reference operator[] (size_t const i) const noexcept
 Returns the i-th element. More...
 
constexpr reference front () noexcept
 Returns the first element. More...
 
constexpr const_reference front () const noexcept
 Returns the first element. More...
 
constexpr reference back () noexcept
 Returns the last element. More...
 
constexpr const_reference back () const noexcept
 Returns the last element. More...
 
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. More...
 
Capacity
constexpr bool empty () const noexcept
 Checks whether the container is empty. More...
 
constexpr size_type size () const noexcept
 Returns the number of elements in the container, i.e. std::distance(begin(), end()). More...
 
constexpr size_type max_size () const noexcept
 Returns the maximum number of elements the container is able to hold and resolves to bit_capacity. More...
 
constexpr size_type capacity () const noexcept
 Returns the number of elements that the container is able to hold and resolves to bit_capacity. More...
 
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. More...
 
constexpr iterator insert (const_iterator pos, value_type const value) noexcept
 Inserts value before pos in the container. More...
 
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. More...
 
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. More...
 
constexpr iterator insert (const_iterator pos, std::initializer_list< value_type > const &ilist) noexcept
 Inserts elements from initializer list before pos in the container. More...
 
constexpr iterator erase (const_iterator begin_it, const_iterator end_it) noexcept
 Removes specified elements from the container. More...
 
constexpr iterator erase (const_iterator pos) noexcept
 Removes specified elements from the container. More...
 
constexpr void push_back (value_type const value) noexcept
 Appends the given element value to the end of the container. More...
 
constexpr void pop_back () noexcept
 Removes the last element of the container. More...
 
constexpr void resize (size_type const count, value_type const value=false) noexcept
 Resizes the container to contain count elements. More...
 
constexpr void swap (dynamic_bitset &rhs) noexcept
 Swap contents with another instance. More...
 
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
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. More...
 
constexpr unsigned long to_ulong () const
 Converts the dynamic_bitset to an unsigned long integer. More...
 
constexpr unsigned long long to_ullong () const
 Converts the dynamic_bitset to an unsigned long long integer. More...
 

Related Functions

(Note that these are not member functions.)

constexpr shape operator""_shape (unsigned long long const value)
 The seqan3::shape literal. More...
 

Detailed Description

A class that defines which positions of a pattern to hash.

When hashing a sequence, there may be positions that do not count towards the final hash value. A shape offers an easy way to define such patterns. Given a k-mer length k (0 < k <= 58), a shape represents a binary sequence where a 0 encodes a "don't care position", i.e. a position that is not taken into account when computing the hash value. A 1 therefore translates to a position that is used to compute the hash value.

Example

#include <seqan3/core/debug_stream.hpp> // For seqan3::debug_stream
#include <seqan3/search/kmer_index/shape.hpp> // For seqan3::shape
#include <seqan3/std/ranges> // For std::ranges::size()
using seqan3::operator""_shape;
int main()
{
seqan3::shape s0{seqan3::ungapped{5}}; // represents "11111", i.e. ungapped 5-mer
seqan3::debug_stream << s0 << '\n'; // prints "[1,1,1,1,1]"
seqan3::debug_stream << std::ranges::size(s0) << '\n'; // prints "5"
seqan3::shape s1{seqan3::bin_literal{0b101}}; // represents "101", i.e. gapped 3-mer
seqan3::debug_stream << s1 << '\n'; // prints "[1,0,1]"
seqan3::debug_stream << std::ranges::size(s1) << '\n'; // prints "3"
seqan3::shape s2{0b101_shape}; // Same as previous
seqan3::debug_stream << s2 << '\n'; // prints "[1,0,1]"
seqan3::debug_stream << std::ranges::size(s2) << '\n'; // prints "3"
}
Attention
0 < size <= 58

Constructor & Destructor Documentation

◆ shape() [1/2]

constexpr seqan3::shape::shape ( ungapped  k)
inlineconstexprnoexcept

Construct an ungapped shape from a given size.

Complexity

Linear in k.

Exceptions

No-throw guarantee.

Attention
The size must be in the interval [1, 58]. In Debug mode, an assertion will check this constraint.

◆ shape() [2/2]

constexpr seqan3::shape::shape ( bin_literal const  literal)
inlineconstexprnoexcept

Construct from a given seqan3::bin_literal.

Complexity

Linear in the size of the bin_literal.

Exceptions

No-throw guarantee.

Attention
The size of the bin_literal must be in the interval [1, 58].

Member Function Documentation

◆ all()

constexpr bool seqan3::dynamic_bitset< bit_capacity >::all
inlineconstexprnoexceptinherited

Checks if all bit are set.

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

◆ any()

constexpr bool seqan3::dynamic_bitset< bit_capacity >::any
inlineconstexprnoexceptinherited

Checks if any bit is set.

Returns
true if any bit is set, false otherwise.

◆ assign() [1/5]

constexpr void seqan3::dynamic_bitset< bit_capacity >::assign ( begin_it_type  begin_it,
end_it_type  end_it 
)
inlineconstexprnoexceptinherited

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.

◆ assign() [2/5]

constexpr void seqan3::dynamic_bitset< bit_capacity >::assign ( char const (&)  lit[N])
inlineconstexprinherited

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'.

◆ assign() [3/5]

constexpr void seqan3::dynamic_bitset< bit_capacity >::assign ( other_range_t &&  range)
inlineconstexprnoexceptinherited

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.

◆ assign() [4/5]

constexpr void seqan3::dynamic_bitset< bit_capacity >::assign ( size_type const  count,
value_type const  value 
)
inlineconstexprnoexceptinherited

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.

◆ assign() [5/5]

constexpr void seqan3::dynamic_bitset< bit_capacity >::assign ( std::initializer_list< value_type > const  ilist)
inlineconstexprnoexceptinherited

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.

◆ at() [1/2]

constexpr reference seqan3::dynamic_bitset< bit_capacity >::at ( size_t const  i)
inlineconstexprinherited

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().

◆ at() [2/2]

constexpr const_reference seqan3::dynamic_bitset< bit_capacity >::at ( size_t const  i) const
inlineconstexprinherited

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().

◆ back() [1/2]

constexpr const_reference seqan3::dynamic_bitset< bit_capacity >::back
inlineconstexprnoexceptinherited

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.

◆ back() [2/2]

constexpr reference seqan3::dynamic_bitset< bit_capacity >::back
inlineconstexprnoexceptinherited

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.

◆ begin() [1/2]

constexpr const_iterator seqan3::dynamic_bitset< bit_capacity >::begin
inlineconstexprnoexceptinherited

Returns the begin to the dynamic_bitset.

Example

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
}

◆ begin() [2/2]

constexpr iterator seqan3::dynamic_bitset< bit_capacity >::begin
inlineconstexprnoexceptinherited

Returns the begin to the dynamic_bitset.

Example

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
}

◆ capacity()

constexpr size_type seqan3::dynamic_bitset< bit_capacity >::capacity
inlineconstexprnoexceptinherited

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.

◆ cbegin()

constexpr const_iterator seqan3::dynamic_bitset< bit_capacity >::cbegin
inlineconstexprnoexceptinherited

Returns the begin to the dynamic_bitset.

Example

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
}

◆ cend()

constexpr const_iterator seqan3::dynamic_bitset< bit_capacity >::cend
inlineconstexprnoexceptinherited

Returns iterator past the end of the dynamic_bitset.

Example

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
}

◆ clear()

constexpr void seqan3::dynamic_bitset< bit_capacity >::clear
inlineconstexprnoexceptinherited

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.

◆ empty()

constexpr bool seqan3::dynamic_bitset< bit_capacity >::empty
inlineconstexprnoexceptinherited

Checks whether the container is empty.

Returns
true if the container is empty, false otherwise.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ end() [1/2]

constexpr const_iterator seqan3::dynamic_bitset< bit_capacity >::end
inlineconstexprnoexceptinherited

Returns iterator past the end of the dynamic_bitset.

Example

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
}

◆ end() [2/2]

constexpr iterator seqan3::dynamic_bitset< bit_capacity >::end
inlineconstexprnoexceptinherited

Returns iterator past the end of the dynamic_bitset.

Example

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
}

◆ erase() [1/2]

constexpr iterator seqan3::dynamic_bitset< bit_capacity >::erase ( const_iterator  begin_it,
const_iterator  end_it 
)
inlineconstexprnoexceptinherited

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.

◆ erase() [2/2]

constexpr iterator seqan3::dynamic_bitset< bit_capacity >::erase ( const_iterator  pos)
inlineconstexprnoexceptinherited

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.

◆ flip() [1/2]

constexpr dynamic_bitset& seqan3::dynamic_bitset< bit_capacity >::flip
inlineconstexprnoexceptinherited

Flips all bits (binary NOT).

Returns
*this

Example

int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1.flip();
seqan3::debug_stream << t1 << '\n'; // 0111'0011
}

Exception

No-throw guarantee.

Complexity

Constant.

◆ flip() [2/2]

constexpr dynamic_bitset& seqan3::dynamic_bitset< bit_capacity >::flip ( size_t const  i)
inlineconstexprinherited

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

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.

◆ front() [1/2]

constexpr const_reference seqan3::dynamic_bitset< bit_capacity >::front
inlineconstexprnoexceptinherited

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.

◆ front() [2/2]

constexpr reference seqan3::dynamic_bitset< bit_capacity >::front
inlineconstexprnoexceptinherited

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.

◆ insert() [1/4]

constexpr iterator seqan3::dynamic_bitset< bit_capacity >::insert ( const_iterator  pos,
begin_it_type  begin_it,
end_it_type  end_it 
)
inlineconstexprnoexceptinherited

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.

◆ insert() [2/4]

constexpr iterator seqan3::dynamic_bitset< bit_capacity >::insert ( const_iterator  pos,
size_type const  count,
value_type const  value 
)
inlineconstexprnoexceptinherited

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.

◆ insert() [3/4]

constexpr iterator seqan3::dynamic_bitset< bit_capacity >::insert ( const_iterator  pos,
std::initializer_list< value_type > const &  ilist 
)
inlineconstexprnoexceptinherited

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.

◆ insert() [4/4]

constexpr iterator seqan3::dynamic_bitset< bit_capacity >::insert ( const_iterator  pos,
value_type const  value 
)
inlineconstexprnoexceptinherited

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.

◆ max_size()

constexpr size_type seqan3::dynamic_bitset< bit_capacity >::max_size
inlineconstexprnoexceptinherited

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.

◆ none()

constexpr bool seqan3::dynamic_bitset< bit_capacity >::none
inlineconstexprnoexceptinherited

Checks if no bit is set.

Returns
true if no bit is set, false otherwise.

◆ operator&=()

constexpr dynamic_bitset& seqan3::dynamic_bitset< bit_capacity >::operator&= ( dynamic_bitset< 58 > const &  rhs)
inlineconstexprnoexceptinherited

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

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.

◆ operator<<()

constexpr dynamic_bitset seqan3::dynamic_bitset< bit_capacity >::operator<< ( size_t const  count) const
inlineconstexprnoexceptinherited

Performs binary shift left.

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

Example

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.

◆ operator<<=()

constexpr dynamic_bitset& seqan3::dynamic_bitset< bit_capacity >::operator<<= ( size_t const  count)
inlineconstexprnoexceptinherited

Performs binary shift left on the current object.

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

Example

int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1 <<= 3;
seqan3::debug_stream << t1 << '\n'; // 0110'0000
}

Exception

No-throw guarantee.

Complexity

Constant.

◆ operator>>()

constexpr dynamic_bitset seqan3::dynamic_bitset< bit_capacity >::operator>> ( size_t const  count) const
inlineconstexprnoexceptinherited

Performs binary shift right.

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

Example

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.

◆ operator>>=()

constexpr dynamic_bitset& seqan3::dynamic_bitset< bit_capacity >::operator>>= ( size_t const  count)
inlineconstexprnoexceptinherited

Performs binary shift right on the current object.

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

Example

int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1 >>= 3;
seqan3::debug_stream << t1 << '\n'; // 0001'0001
}

Exception

No-throw guarantee.

Complexity

Constant.

◆ operator[]() [1/2]

constexpr const_reference seqan3::dynamic_bitset< bit_capacity >::operator[] ( size_t const  i) const
inlineconstexprnoexceptinherited

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

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.

◆ operator[]() [2/2]

constexpr reference seqan3::dynamic_bitset< bit_capacity >::operator[] ( size_t const  i)
inlineconstexprnoexceptinherited

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

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.

◆ operator^=()

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

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

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.

◆ operator|=()

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

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

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.

◆ operator~()

constexpr dynamic_bitset seqan3::dynamic_bitset< bit_capacity >::operator~
inlineconstexprnoexceptinherited

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

Returns
Copy of *this with all bits flipped.

Example

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.

◆ pop_back()

constexpr void seqan3::dynamic_bitset< bit_capacity >::pop_back
inlineconstexprnoexceptinherited

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.

◆ push_back()

constexpr void seqan3::dynamic_bitset< bit_capacity >::push_back ( value_type const  value)
inlineconstexprnoexceptinherited

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.

◆ raw_data()

constexpr bitfield const* seqan3::dynamic_bitset< bit_capacity >::raw_data
inlineconstexprnoexceptinherited

Direct access to the underlying bit field.

◆ reset() [1/2]

constexpr dynamic_bitset& seqan3::dynamic_bitset< bit_capacity >::reset
inlineconstexprnoexceptinherited

Sets all bits to 0.

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

Example

int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1.reset();
seqan3::debug_stream << t1 << '\n'; // 0000'0000
}

Exception

No-throw guarantee.

Complexity

Constant.

◆ reset() [2/2]

constexpr dynamic_bitset& seqan3::dynamic_bitset< bit_capacity >::reset ( size_t const  i)
inlineconstexprinherited

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

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.

◆ resize()

constexpr void seqan3::dynamic_bitset< bit_capacity >::resize ( size_type const  count,
value_type const  value = false 
)
inlineconstexprnoexceptinherited

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

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
}

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ set() [1/2]

constexpr dynamic_bitset& seqan3::dynamic_bitset< bit_capacity >::set
inlineconstexprnoexceptinherited

Sets all bits to 1.

Returns
*this

Example

int main()
{
seqan3::dynamic_bitset t1{"10001100"};
t1.set();
seqan3::debug_stream << t1 << '\n'; // 1111'1111
}

Exception

No-throw guarantee.

Complexity

Constant.

◆ set() [2/2]

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

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

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.

◆ size()

constexpr size_type seqan3::dynamic_bitset< bit_capacity >::size
inlineconstexprnoexceptinherited

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.

◆ swap()

constexpr void seqan3::dynamic_bitset< bit_capacity >::swap ( dynamic_bitset< 58 > &  rhs)
inlineconstexprnoexceptinherited

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.

◆ test()

constexpr const_reference seqan3::dynamic_bitset< bit_capacity >::test ( size_t const  i) const
inlineconstexprinherited

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().

◆ to_string()

std::string seqan3::dynamic_bitset< bit_capacity >::to_string ( char_t  zero = char_t{'0'},
char_t  one = char_t{'1'} 
) const
inlineinherited

Converts the dynamic_bitset to a std::string.

Template Parameters
char_tChar type; must model seqan3::builtin_character.
Parameters
[in]zerobuiltin_characteracter of type char_t representing false. Default '0'.
[in]onebuiltin_characteracter 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.

◆ to_ullong()

constexpr unsigned long long seqan3::dynamic_bitset< bit_capacity >::to_ullong
inlineconstexprinherited

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.

◆ to_ulong()

constexpr unsigned long seqan3::dynamic_bitset< bit_capacity >::to_ulong
inlineconstexprinherited

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.

Friends And Related Function Documentation

◆ operator""_shape()

constexpr shape operator""_shape ( unsigned long long const  value)
related

The seqan3::shape literal.

Parameters
[in]valueThe unsigned integer to assign.
Returns
seqan3::shape

The documentation for this class was generated from the following file:
debug_stream.hpp
Provides seqan3::debug_stream and related types.
seqan3::shape
A class that defines which positions of a pattern to hash.
Definition: shape.hpp:58
seqan3::dynamic_bitset
A constexpr bitset implementation with dynamic size at compile time.
Definition: dynamic_bitset.hpp:50
shape.hpp
Provides seqan3::shape.
seqan3::ungapped
A strong type of underlying type uint8_t that represents the ungapped shape size.
Definition: shape.hpp:25
seqan3::bin_literal
A strong type of underlying type uint64_t that represents the shape in binary representation.
Definition: shape.hpp:34
seqan3::dynamic_bitset::resize
constexpr void resize(size_type const count, value_type const value=false) noexcept
Resizes the container to contain count elements.
Definition: dynamic_bitset.hpp:1463
seqan3::dynamic_bitset::reset
constexpr dynamic_bitset & reset() noexcept
Sets all bits to 0.
Definition: dynamic_bitset.hpp:845
seqan3::pack_traits::size
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:116
ranges
Adaptations of concepts from the Ranges TS.
seqan3::dynamic_bitset::set
constexpr dynamic_bitset & set() noexcept
Sets all bits to 1.
Definition: dynamic_bitset.hpp:793
dynamic_bitset.hpp
A constexpr bitset implementation with dynamic size at compile time.
seqan3::debug_stream
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:42
seqan3::dynamic_bitset::flip
constexpr dynamic_bitset & flip() noexcept
Flips all bits (binary NOT).
Definition: dynamic_bitset.hpp:893