A class that defines which positions of a pattern to hash. More...
#include <seqan3/search/kmer_index/shape.hpp>
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 shape & | operator= (shape const &) noexcept=default |
Defaulted. | |
constexpr shape & | operator= (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_bitset & | operator&= (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_bitset & | operator|= (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_bitset & | operator^= (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_bitset & | operator<<= (size_t const count) noexcept |
Performs binary shift left on the current object. More... | |
constexpr dynamic_bitset & | operator>>= (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_bitset & | set () noexcept |
Sets all bits to 1 . More... | |
constexpr dynamic_bitset & | set (size_t const i, bool const value=true) |
Sets the i'th bit to value . More... | |
constexpr dynamic_bitset & | reset () noexcept |
Sets all bits to 0 . More... | |
constexpr dynamic_bitset & | reset (size_t const i) |
Sets the i'th bit to false. More... | |
constexpr dynamic_bitset & | flip () noexcept |
Flips all bits (binary NOT). More... | |
constexpr dynamic_bitset & | flip (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... | |
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.
|
inlineconstexprnoexcept |
Construct an ungapped shape from a given size.
Linear in k
.
No-throw guarantee.
|
inlineconstexprnoexcept |
Construct from a given seqan3::bin_literal.
Linear in the size of the bin_literal
.
No-throw guarantee.
bin_literal
must be in the interval [1, 58].
|
inlineconstexprnoexceptinherited |
Checks if all bit are set.
true
if all bits are set or the bitset is empty, false
otherwise.
|
inlineconstexprnoexceptinherited |
Checks if any bit is set.
true
if any bit is set, false
otherwise.
|
inlineconstexprnoexceptinherited |
Assign from pair of iterators.
begin_it_type | Must model std::forward_iterator and the value_type must be constructible from the reference type of begin_it_type . |
end_it_type | Must model std::sentinel_for. |
[in] | begin_it | Begin of range to construct/assign from. |
[in] | end_it | End of range to construct/assign from. |
Linear in the distance between begin_it
and end_it
.
No-throw guarantee.
|
inlineconstexprinherited |
Assign from literal.
[in] | lit | The literal to assign the string from. May only contain '0' and '1' . |
std::invalid_argument | if 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
.
Linear in the size of lit
.
Throws std::invalid_argument if any character is not '0'
or '1'
.
|
inlineconstexprnoexceptinherited |
Assign from a different range.
other_range_t | The 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> . |
[in] | range | The sequences to construct/assign from. |
Linear in the size of range
.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Assign with count
times value
.
[in] | count | Number of elements. |
[in] | value | The initial value to be assigned. |
Linear in count
.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Assign from std::initializer_list
.
[in] | ilist | A std::initializer_list of value_type . |
Linear in the size of ilist
.
No-throw guarantee.
|
inlineconstexprinherited |
Returns the i-th element.
[in] | i | Index of the element to retrieve. |
std::out_of_range | If you access an element behind the last. |
i
.Constant.
Throws std::out_of_range if i >= size()
.
|
inlineconstexprinherited |
Returns the i-th element.
[in] | i | Index of the element to retrieve. |
std::out_of_range | If you access an element behind the last. |
i
.Constant.
Throws std::out_of_range if i >= size()
.
|
inlineconstexprnoexceptinherited |
Returns the last element.
Calling back()
on an empty container is undefined. In debug mode an assertion checks the size of the container.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Returns the last element.
Calling back()
on an empty container is undefined. In debug mode an assertion checks the size of the container.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Returns the begin to the dynamic_bitset
.
|
inlineconstexprnoexceptinherited |
Returns the begin to the dynamic_bitset
.
|
inlineconstexprnoexceptinherited |
Returns the number of elements that the container is able to hold and resolves to bit_capacity
.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Returns the begin to the dynamic_bitset
.
|
inlineconstexprnoexceptinherited |
Returns iterator past the end of the dynamic_bitset
.
|
inlineconstexprnoexceptinherited |
Removes all elements from the container.
reset()
, this method also sets the size to 0.Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Checks whether the container is empty.
true
if the container is empty, false
otherwise.Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Returns iterator past the end of the dynamic_bitset
.
|
inlineconstexprnoexceptinherited |
Returns iterator past the end of the dynamic_bitset
.
|
inlineconstexprnoexceptinherited |
Removes specified elements from the container.
[in] | begin_it | Begin of range to erase. |
[in] | end_it | Behind the end of range to erase. |
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.
Linear in size()
.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Removes specified elements from the container.
[in] | pos | Remove the element at pos. |
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
.
Linear in size()
.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Flips all bits (binary NOT).
No-throw guarantee.
Constant.
|
inlineconstexprinherited |
Flips the i'th bit (binary NOT).
[in] | i | Index of the bit to flip. |
std::out_of_range | if you access an element behind the last. |
Throws std::out_of_range if i >= size()
.
Constant.
|
inlineconstexprnoexceptinherited |
Returns the first element.
Calling front()
on an empty container is undefined. In debug mode an assertion checks the size of the container.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Returns the first element.
Calling front()
on an empty container is undefined. In debug mode an assertion checks the size of the container.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Inserts elements from range [begin_it, end_it)
before pos
in the container.
begin_it_type | Must model std::forward_iterator and the value_type must be constructible from the reference type of begin_it_type. |
end_it_type | Must model std::sentinel_for. |
[in] | pos | Iterator before which the content will be inserted. pos may be the end() iterator. |
[in] | begin_it | Begin of range to construct/assign from. |
[in] | end_it | End of range to construct/assign from. |
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()
.
Worst-case linear in size()
.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Inserts count
copies of value
before position in the container.
[in] | pos | Iterator before which the content will be inserted. pos may be the end() iterator. |
[in] | count | Number of copies. |
[in] | value | Element value to insert. |
pos
if count==0
.If size()
+ count
> capacity()
this function results in undefined behaviour.
Worst-case linear in size()
.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Inserts elements from initializer list before pos
in the container.
[in] | pos | Iterator before which the content will be inserted. pos may be the end() iterator. |
[in] | ilist | Initializer list with values to insert. |
pos
if ilist
is empty.Given the size n
of ilist
, this function results in undefined behaviour if size()
+ n
> capacity()
.
Worst-case linear in size()
.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Inserts value
before pos
in the container.
[in] | pos | Iterator before which the content will be inserted. pos may be the end() iterator. |
[in] | value | Element value to insert. |
Inserting a value although the maximum capacity is reached is undefined behaviour.
Worst-case linear in size()
.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Returns the maximum number of elements the container is able to hold and resolves to bit_capacity
.
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()
.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Checks if no bit is set.
true
if no bit is set, false
otherwise.
|
inlineconstexprnoexceptinherited |
Sets the bits to the result of binary AND on corresponding pairs of bits of *this
and rhs
.
[in] | rhs | dynamic_bitset to perform binary AND with. |
No-throw guarantee.
Constant.
|
inlineconstexprnoexceptinherited |
Performs binary shift left.
[in] | count | Amount to shift to the left. |
No-throw guarantee.
Constant.
|
inlineconstexprnoexceptinherited |
Performs binary shift left on the current object.
[in] | count | Amount to shift to the left. |
No-throw guarantee.
Constant.
|
inlineconstexprnoexceptinherited |
Performs binary shift right.
[in] | count | Amount to shift to the right. |
No-throw guarantee.
Constant.
|
inlineconstexprnoexceptinherited |
Performs binary shift right on the current object.
[in] | count | Amount to shift to the right. |
No-throw guarantee.
Constant.
|
inlineconstexprnoexceptinherited |
Returns the i-th element.
[in] | i | The element to retrieve. |
i
.Accessing an element behind the last causes undefined behaviour. In debug mode an assertion checks the size of the container.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Returns the i-th element.
[in] | i | The element to retrieve. |
i
.Accessing an element behind the last causes undefined behaviour. In debug mode an assertion checks the size of the container.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Sets the bits to the result of binary XOR on corresponding pairs of bits of *this
and rhs
.
[in] | rhs | dynamic_bitset to perform binary XOR with. |
No-throw guarantee.
Constant.
|
inlineconstexprnoexceptinherited |
Sets the bits to the result of binary OR on corresponding pairs of bits of *this
and rhs
.
[in] | rhs | dynamic_bitset to perform binary OR with. |
No-throw guarantee.
Constant.
|
inlineconstexprnoexceptinherited |
Returns a temporary copy of *this
with all bits flipped (binary NOT).
No-throw guarantee.
Thread safe.
Constant.
|
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.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Appends the given element value
to the end of the container.
[in] | value | The value to append. |
If the new size(
) is greater than capacity()
this is undefined behaviour.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Direct access to the underlying bit field.
|
inlineconstexprnoexceptinherited |
Sets all bits to 0
.
clear()
, this method does not modify the size.No-throw guarantee.
Constant.
|
inlineconstexprinherited |
Sets the i'th bit to false.
[in] | i | Index of the bit to reset. |
std::out_of_range | if you access an element behind the last. |
Throws std::out_of_range if i >= size()
.
Constant.
|
inlineconstexprnoexceptinherited |
Resizes the container to contain count elements.
[in] | count | The new size. |
[in] | value | Append 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
.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Sets all bits to 1
.
No-throw guarantee.
Constant.
|
inlineconstexprinherited |
Sets the i'th bit to value
.
[in] | i | Index of the bit to set. |
[in] | value | Value to set. Default true. |
std::out_of_range | if you access an element behind the last. |
Throws std::out_of_range if i >= size()
.
Constant.
|
inlineconstexprnoexceptinherited |
Returns the number of elements in the container, i.e. std::distance(begin(), end())
.
Constant.
No-throw guarantee.
|
inlineconstexprnoexceptinherited |
Swap contents with another instance.
[in] | rhs | The other instance to swap with. |
Linear in the size of both containers.
No-throw guarantee if value_type is std::is_nothrow_copy_constructible.
|
inlineconstexprinherited |
Returns the i-th element.
[in] | i | Index of the element to retrieve. |
std::out_of_range | If you access an element behind the last. |
i
.Constant.
Throws std::out_of_range if i >= size()
.
|
inlineinherited |
Converts the dynamic_bitset
to a std::string
.
char_t | Char type; must model seqan3::builtin_character. |
[in] | zero | builtin_characteracter of type char_t representing false . Default '0' . |
[in] | one | builtin_characteracter of type char_t representing true . Default '1' . |
std::bad_alloc | from the the std::string constructor. |
std::string
representing the dynamic_bitset
.std::string
is not constexpr.Linear in size()
.
Throws std::bad_alloc from the std::string
constructor.
|
inlineconstexprinherited |
Converts the dynamic_bitset
to an unsigned long long
integer.
std::overflow_error | if the value cannot be represented in unsigned long long . |
unsigned long long
representing the dynamic_bitset
.Constant.
Throws std::overflow_error if the value cannot be represented in unsigned long long
.
|
inlineconstexprinherited |
Converts the dynamic_bitset
to an unsigned long
integer.
std::overflow_error | if the value cannot be represented in unsigned long . |
unsigned long
representing the dynamic_bitset
.Constant.
Throws std::overflow_error if the value cannot be represented in unsigned long
.
|
related |