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

A space-optimised version of std::vector that compresses multiple letters into a single byte. More...

#include <seqan3/alphabet/container/bitpacked_sequence.hpp>

+ Inheritance diagram for seqan3::bitpacked_sequence< alphabet_type >:

Public Types

Associated types
using value_type = alphabet_type
 Equals the alphabet_type.
 
using reference = reference_proxy_type
 A proxy type (models seqan3::writable_semialphabet) that enables assignment, think of it as value_type &.
 
using const_reference = alphabet_type
 Equals the alphabet_type / value_type.
 
using iterator = detail::random_access_iterator< bitpacked_sequence >
 The iterator type of this container (a random access iterator).
 
using const_iterator = detail::random_access_iterator< bitpacked_sequence const >
 The const_iterator type of this container (a random access iterator).
 
using difference_type = std::ranges::range_difference_t< data_type >
 A signed integer type (usually std::ptrdiff_t)
 
using size_type = std::ranges::range_size_t< data_type >
 An unsigned integer type (usually std::size_t)
 

Public Member Functions

Constructors, destructor and assignment
 bitpacked_sequence ()=default
 Defaulted.
 
constexpr bitpacked_sequence (bitpacked_sequence const &)=default
 Defaulted.
 
constexpr bitpacked_sequence (bitpacked_sequence &&)=default
 Defaulted.
 
constexpr bitpacked_sequenceoperator= (bitpacked_sequence const &)=default
 Defaulted.
 
constexpr bitpacked_sequenceoperator= (bitpacked_sequence &&)=default
 Defaulted.
 
 ~bitpacked_sequence ()=default
 Defaulted.
 
template<typename other_range_t >
requires (!std::same_as<bitpacked_sequence, std::remove_cvref_t<other_range_t>>) && std::ranges::input_range<other_range_t> && has_same_value_type_v<other_range_t>
 bitpacked_sequence (other_range_t &&range)
 Construct from a different range.
 
 bitpacked_sequence (size_type const count, value_type const value)
 Construct with count times value.
 
template<std::forward_iterator begin_iterator_type, typename end_iterator_type >
requires std::sentinel_for<end_iterator_type, begin_iterator_type> && std::common_reference_with<std::iter_value_t<begin_iterator_type>, value_type>
 bitpacked_sequence (begin_iterator_type begin_it, end_iterator_type end_it)
 Construct from pair of iterators.
 
 bitpacked_sequence (std::initializer_list< value_type > ilist)
 Construct from std::initializer_list.
 
bitpacked_sequenceoperator= (std::initializer_list< value_type > ilist)
 Assign from std::initializer_list.
 
template<std::ranges::input_range other_range_t>
requires std::common_reference_with<std::ranges::range_value_t<other_range_t>, value_type>
void assign (other_range_t &&range)
 Assign from a different range.
 
void assign (size_type const count, value_type const value)
 Assign with count times value.
 
template<std::forward_iterator begin_iterator_type, typename end_iterator_type >
requires std::sentinel_for<end_iterator_type, begin_iterator_type> && std::common_reference_with<std::iter_value_t<begin_iterator_type>, value_type>
void assign (begin_iterator_type begin_it, end_iterator_type end_it)
 Assign from pair of iterators.
 
void assign (std::initializer_list< value_type > ilist)
 Assign from std::initializer_list.
 
Iterators
iterator begin () noexcept
 Returns an iterator to the first element of the container.
 
const_iterator begin () const noexcept
 Returns an iterator to the first element of the container.
 
const_iterator cbegin () const noexcept
 Returns an iterator to the first element of the container.
 
iterator end () noexcept
 Returns an iterator to the element following the last element of the container.
 
const_iterator end () const noexcept
 Returns an iterator to the element following the last element of the container.
 
const_iterator cend () const noexcept
 Returns an iterator to the element following the last element of the container.
 
Element access
reference at (size_type const i)
 Return the i-th element.
 
const_reference at (size_type const i) const
 Return the i-th element.
 
reference operator[] (size_type const i) noexcept
 Return the i-th element.
 
const_reference operator[] (size_type const i) const noexcept
 Return the i-th element.
 
reference front () noexcept
 Return the first element. Calling front on an empty container is undefined.
 
const_reference front () const noexcept
 Return the first element. Calling front on an empty container is undefined.
 
reference back () noexcept
 Return the last element.
 
const_reference back () const noexcept
 Return the last element.
 
constexpr data_type & raw_data () noexcept
 Provides direct, unsafe access to underlying data structures.
 
constexpr data_type const & raw_data () const noexcept
 Provides direct, unsafe access to underlying data structures.
 
Capacity
bool empty () const noexcept
 Checks whether the container is empty.
 
size_type size () const noexcept
 Returns the number of elements in the container, i.e. std::distance(begin(), end()).
 
size_type max_size () const noexcept
 Returns the maximum number of elements the container is able to hold due to system or library implementation limitations, i.e. std::distance(begin(), end()) for the largest container.
 
size_type capacity () const noexcept
 Returns the number of elements that the container has currently allocated space for.
 
void reserve (size_type const new_cap)
 Increase the capacity to a value that's greater or equal to new_cap.
 
void shrink_to_fit ()
 Requests the removal of unused capacity.
 
Comparison operators
constexpr bool operator== (bitpacked_sequence const &rhs) const noexcept
 Checks whether *this is equal to rhs.
 
constexpr bool operator!= (bitpacked_sequence const &rhs) const noexcept
 Checks whether *this is not equal to rhs.
 
constexpr bool operator< (bitpacked_sequence const &rhs) const noexcept
 Checks whether *this is less than rhs.
 
constexpr bool operator> (bitpacked_sequence const &rhs) const noexcept
 Checks whether *this is greater than rhs.
 
constexpr bool operator<= (bitpacked_sequence const &rhs) const noexcept
 Checks whether *this is less than or equal to rhs.
 
constexpr bool operator>= (bitpacked_sequence const &rhs) const noexcept
 Checks whether *this is greater than or equal to rhs.
 

Modifiers

void clear () noexcept
 Removes all elements from the container.
 
iterator insert (const_iterator pos, value_type const value)
 Inserts value before position in the container.
 
iterator insert (const_iterator pos, size_type const count, value_type const value)
 Inserts count copies of value before position in the container.
 
template<std::forward_iterator begin_iterator_type, typename end_iterator_type >
requires std::sentinel_for<end_iterator_type, begin_iterator_type> && std::common_reference_with<std::iter_value_t<begin_iterator_type>, value_type>
iterator insert (const_iterator pos, begin_iterator_type begin_it, end_iterator_type end_it)
 Inserts elements from range [begin_it, end_it) before position in the container.
 
iterator insert (const_iterator pos, std::initializer_list< value_type > const &ilist)
 Inserts elements from initializer list before position in the container.
 
iterator erase (const_iterator begin_it, const_iterator end_it)
 Removes specified elements from the container.
 
iterator erase (const_iterator pos)
 Removes specified elements from the container.
 
void push_back (value_type const value)
 Appends the given element value to the end of the container.
 
void pop_back ()
 Removes the last element of the container.
 
void resize (size_type const count)
 Resizes the container to contain count elements.
 
void resize (size_type const count, value_type const value)
 Resizes the container to contain count elements.
 
constexpr void swap (bitpacked_sequence &rhs) noexcept
 Swap contents with another instance.
 
constexpr void swap (bitpacked_sequence &&rhs) noexcept
 Swap contents with another instance.
 
constexpr void swap (bitpacked_sequence &lhs, bitpacked_sequence &rhs) noexcept
 Swap contents with another instance.
 
constexpr void swap (bitpacked_sequence &&lhs, bitpacked_sequence &&rhs) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Detailed Description

template<writable_semialphabet alphabet_type>
requires std::regular<alphabet_type>
class seqan3::bitpacked_sequence< alphabet_type >

A space-optimised version of std::vector that compresses multiple letters into a single byte.

Template Parameters
alphabet_typeThe value type of the container, must satisfy seqan3::writable_semialphabet and std::regular.

This class template behaves just like std::vector<alphabet_type> but has an internal representation where multiple values are packed into a single byte/word to save space, e.g. seqan3::bitpacked_sequence<seqan3::dna4> uses a quarter of of the memory that std::vector<seqan3::dna4> uses, because a single seqan3::dna4 letter can be represented in two bits (instead of 8 which is the lower bound for a single object in C++).

The disadvantages are slightly slower operations and unsafety towards parallel writes to adjacent positions in the seqan3::bitpacked_sequence.

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
#include <vector>
int main()
{
using namespace seqan3::literals;
std::vector<seqan3::dna4> v0{"ACGT"_dna4}; // data occupies 4 bytes in memory
seqan3::bitpacked_sequence<seqan3::dna4> v1{"ACGT"_dna4}; // data occupies 1 byte in memory
}
Provides seqan3::bitpacked_sequence.
A space-optimised version of std::vector that compresses multiple letters into a single byte.
Definition bitpacked_sequence.hpp:63
Provides seqan3::dna4, container aliases and string literals.
The SeqAn namespace for literals.

Thread safety

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

An important difference to std::vector is that calling vec[i] = value; and vec[j] = value2; from two different threads at the same time is not safe and will lead to corruption if both values are stored in the same 64bit-block, i.e. if the distance between i and j is smaller than 64 / alphabet_size.

This entity is stable. Since version 3.1.

Member Typedef Documentation

◆ const_iterator

template<writable_semialphabet alphabet_type>
using seqan3::bitpacked_sequence< alphabet_type >::const_iterator = detail::random_access_iterator<bitpacked_sequence const>

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

This entity is stable. Since version 3.1.

◆ const_reference

template<writable_semialphabet alphabet_type>
using seqan3::bitpacked_sequence< alphabet_type >::const_reference = alphabet_type

Equals the alphabet_type / value_type.

This entity is stable. Since version 3.1.

◆ difference_type

template<writable_semialphabet alphabet_type>
using seqan3::bitpacked_sequence< alphabet_type >::difference_type = std::ranges::range_difference_t<data_type>

A signed integer type (usually std::ptrdiff_t)

This entity is stable. Since version 3.1.

◆ iterator

template<writable_semialphabet alphabet_type>
using seqan3::bitpacked_sequence< alphabet_type >::iterator = detail::random_access_iterator<bitpacked_sequence>

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

This entity is stable. Since version 3.1.

◆ reference

template<writable_semialphabet alphabet_type>
using seqan3::bitpacked_sequence< alphabet_type >::reference = reference_proxy_type

A proxy type (models seqan3::writable_semialphabet) that enables assignment, think of it as value_type &.

This entity is stable. Since version 3.1.

◆ size_type

template<writable_semialphabet alphabet_type>
using seqan3::bitpacked_sequence< alphabet_type >::size_type = std::ranges::range_size_t<data_type>

An unsigned integer type (usually std::size_t)

This entity is stable. Since version 3.1.

◆ value_type

template<writable_semialphabet alphabet_type>
using seqan3::bitpacked_sequence< alphabet_type >::value_type = alphabet_type

Equals the alphabet_type.

This entity is stable. Since version 3.1.

Constructor & Destructor Documentation

◆ bitpacked_sequence() [1/4]

template<writable_semialphabet alphabet_type>
template<typename other_range_t >
requires (!std::same_as<bitpacked_sequence, std::remove_cvref_t<other_range_t>>) && std::ranges::input_range<other_range_t> && has_same_value_type_v<other_range_t>
seqan3::bitpacked_sequence< alphabet_type >::bitpacked_sequence ( other_range_t &&  range)
inlineexplicit

Construct from a different range.

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

Complexity

Linear in the size of range.

Exceptions

Strong exception guarantee (no data is modified in case an exception is thrown).

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

◆ bitpacked_sequence() [2/4]

template<writable_semialphabet alphabet_type>
seqan3::bitpacked_sequence< alphabet_type >::bitpacked_sequence ( size_type const  count,
value_type const  value 
)
inline

Construct with count times value.

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

Complexity

In \(O(count)\).

Exceptions

Strong exception guarantee (no data is modified in case an exception is thrown).

This entity is stable. Since version 3.1.

◆ bitpacked_sequence() [3/4]

template<writable_semialphabet alphabet_type>
template<std::forward_iterator begin_iterator_type, typename end_iterator_type >
requires std::sentinel_for<end_iterator_type, begin_iterator_type> && std::common_reference_with<std::iter_value_t<begin_iterator_type>, value_type>
seqan3::bitpacked_sequence< alphabet_type >::bitpacked_sequence ( begin_iterator_type  begin_it,
end_iterator_type  end_it 
)
inline

Construct from pair of iterators.

Template Parameters
begin_iterator_typeMust model std::forward_iterator and std::common_reference_with<std::iter_value_t<begin_iterator_type>, value_type>.
end_iterator_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

Strong exception guarantee (no data is modified in case an exception is thrown).

This entity is stable. Since version 3.1.

◆ bitpacked_sequence() [4/4]

template<writable_semialphabet alphabet_type>
seqan3::bitpacked_sequence< alphabet_type >::bitpacked_sequence ( std::initializer_list< value_type ilist)
inline

Construct from std::initializer_list.

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

Complexity

Linear in the size of ilist.

Exceptions

Strong exception guarantee (no data is modified in case an exception is thrown).

This entity is stable. Since version 3.1.

Member Function Documentation

◆ assign() [1/4]

template<writable_semialphabet alphabet_type>
template<std::forward_iterator begin_iterator_type, typename end_iterator_type >
requires std::sentinel_for<end_iterator_type, begin_iterator_type> && std::common_reference_with<std::iter_value_t<begin_iterator_type>, value_type>
void seqan3::bitpacked_sequence< alphabet_type >::assign ( begin_iterator_type  begin_it,
end_iterator_type  end_it 
)
inline

Assign from pair of iterators.

Template Parameters
begin_iterator_typeMust satisfy std::forward_iterator and std::common_reference_with<std::iter_value_t<begin_iterator_type>, value_type>.
end_iterator_typeMust satisfy 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

Strong exception guarantee (no data is modified in case an exception is thrown).

This entity is stable. Since version 3.1.

◆ assign() [2/4]

template<writable_semialphabet alphabet_type>
template<std::ranges::input_range other_range_t>
requires std::common_reference_with<std::ranges::range_value_t<other_range_t>, value_type>
void seqan3::bitpacked_sequence< alphabet_type >::assign ( other_range_t &&  range)
inline

Assign from a different range.

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

Complexity

Linear in the size of range.

Exceptions

Strong exception guarantee (no data is modified in case an exception is thrown).

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

◆ assign() [3/4]

template<writable_semialphabet alphabet_type>
void seqan3::bitpacked_sequence< alphabet_type >::assign ( size_type const  count,
value_type const  value 
)
inline

Assign with count times value.

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

Complexity

In \(O(count)\).

Exceptions

Strong exception guarantee (no data is modified in case an exception is thrown).

This entity is stable. Since version 3.1.

◆ assign() [4/4]

template<writable_semialphabet alphabet_type>
void seqan3::bitpacked_sequence< alphabet_type >::assign ( std::initializer_list< value_type ilist)
inline

Assign from std::initializer_list.

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

Complexity

Linear in the size of ilist.

Exceptions

Strong exception guarantee (no data is modified in case an exception is thrown).

This entity is stable. Since version 3.1.

◆ at() [1/2]

template<writable_semialphabet alphabet_type>
reference seqan3::bitpacked_sequence< alphabet_type >::at ( size_type const  i)
inline

Return 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
Either a writable proxy to the element or a copy (if called in const context).

Complexity

Constant.

Exceptions

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

This entity is stable. Since version 3.1.

◆ at() [2/2]

template<writable_semialphabet alphabet_type>
const_reference seqan3::bitpacked_sequence< alphabet_type >::at ( size_type const  i) const
inline

Return 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
Either a writable proxy to the element or a copy (if called in const context).

Complexity

Constant.

Exceptions

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

This entity is stable. Since version 3.1.

◆ back() [1/2]

template<writable_semialphabet alphabet_type>
const_reference seqan3::bitpacked_sequence< alphabet_type >::back ( ) const
inlinenoexcept

Return the last element.

Returns
Either a writable proxy to the element or a copy (if called in const context).

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 stable. Since version 3.1.

◆ back() [2/2]

template<writable_semialphabet alphabet_type>
reference seqan3::bitpacked_sequence< alphabet_type >::back ( )
inlinenoexcept

Return the last element.

Returns
Either a writable proxy to the element or a copy (if called in const context).

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 stable. Since version 3.1.

◆ begin() [1/2]

template<writable_semialphabet alphabet_type>
const_iterator seqan3::bitpacked_sequence< alphabet_type >::begin ( ) const
inlinenoexcept

Returns an iterator to the first element of the container.

Returns
Iterator to the first element.

If the container is empty, the returned iterator will be equal to end().

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ begin() [2/2]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitpacked_sequence< alphabet_type >::begin ( )
inlinenoexcept

Returns an iterator to the first element of the container.

Returns
Iterator to the first element.

If the container is empty, the returned iterator will be equal to end().

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ capacity()

template<writable_semialphabet alphabet_type>
size_type seqan3::bitpacked_sequence< alphabet_type >::capacity ( ) const
inlinenoexcept

Returns the number of elements that the container has currently allocated space for.

Returns
The capacity of the currently allocated storage.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ cbegin()

template<writable_semialphabet alphabet_type>
const_iterator seqan3::bitpacked_sequence< alphabet_type >::cbegin ( ) const
inlinenoexcept

Returns an iterator to the first element of the container.

Returns
Iterator to the first element.

If the container is empty, the returned iterator will be equal to end().

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ cend()

template<writable_semialphabet alphabet_type>
const_iterator seqan3::bitpacked_sequence< alphabet_type >::cend ( ) const
inlinenoexcept

Returns an iterator to the element following the last element of the container.

Returns
Iterator to the first element.

This element acts as a placeholder; attempting to dereference it results in undefined behaviour.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ clear()

template<writable_semialphabet alphabet_type>
void seqan3::bitpacked_sequence< alphabet_type >::clear ( )
inlinenoexcept

Removes all elements from the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ empty()

template<writable_semialphabet alphabet_type>
bool seqan3::bitpacked_sequence< alphabet_type >::empty ( ) const
inlinenoexcept

Checks whether the container is empty.

Returns
true if the container is empty, false otherwise.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ end() [1/2]

template<writable_semialphabet alphabet_type>
const_iterator seqan3::bitpacked_sequence< alphabet_type >::end ( ) const
inlinenoexcept

Returns an iterator to the element following the last element of the container.

Returns
Iterator to the first element.

This element acts as a placeholder; attempting to dereference it results in undefined behaviour.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ end() [2/2]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitpacked_sequence< alphabet_type >::end ( )
inlinenoexcept

Returns an iterator to the element following the last element of the container.

Returns
Iterator to the first element.

This element acts as a placeholder; attempting to dereference it results in undefined behaviour.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ erase() [1/2]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitpacked_sequence< alphabet_type >::erase ( const_iterator  begin_it,
const_iterator  end_it 
)
inline

Removes specified elements from the container.

Parameters
begin_itBegin of range to erase.
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 first does not need to be dereferenceable if first==end_it: erasing an empty range is a no-op.

Complexity

Linear in size().

Exceptions

Basic exception guarantee, i.e. guaranteed not to leak, but container may contain invalid data after exception is thrown.

This entity is stable. Since version 3.1.

◆ erase() [2/2]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitpacked_sequence< alphabet_type >::erase ( const_iterator  pos)
inline

Removes specified elements from the container.

Parameters
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

Basic exception guarantee, i.e. guaranteed not to leak, but container may contain invalid data after exception is thrown.

This entity is stable. Since version 3.1.

◆ front() [1/2]

template<writable_semialphabet alphabet_type>
const_reference seqan3::bitpacked_sequence< alphabet_type >::front ( ) const
inlinenoexcept

Return the first element. Calling front on an empty container is undefined.

Returns
Either a writable proxy to the element or a copy (if called in const context).

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 stable. Since version 3.1.

◆ front() [2/2]

template<writable_semialphabet alphabet_type>
reference seqan3::bitpacked_sequence< alphabet_type >::front ( )
inlinenoexcept

Return the first element. Calling front on an empty container is undefined.

Returns
Either a writable proxy to the element or a copy (if called in const context).

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 stable. Since version 3.1.

◆ insert() [1/4]

template<writable_semialphabet alphabet_type>
template<std::forward_iterator begin_iterator_type, typename end_iterator_type >
requires std::sentinel_for<end_iterator_type, begin_iterator_type> && std::common_reference_with<std::iter_value_t<begin_iterator_type>, value_type>
iterator seqan3::bitpacked_sequence< alphabet_type >::insert ( const_iterator  pos,
begin_iterator_type  begin_it,
end_iterator_type  end_it 
)
inline

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

Template Parameters
begin_iterator_typeMust satisfy std::forward_iterator and std::common_reference_with<std::iter_value_t<begin_iterator_type>, value_type>.
end_iterator_typeMust satisfy 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.

Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.

Complexity

Worst-case linear in size().

Exceptions

Basic exception guarantee, i.e. guaranteed not to leak, but container may contain invalid data after exception is thrown.

This entity is stable. Since version 3.1.

◆ insert() [2/4]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitpacked_sequence< alphabet_type >::insert ( const_iterator  pos,
size_type const  count,
value_type const  value 
)
inline

Inserts count copies of value before position in the container.

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

Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.

Complexity

Worst-case linear in size().

Exceptions

Basic exception guarantee, i.e. guaranteed not to leak, but container may contain invalid data after exception is thrown.

This entity is stable. Since version 3.1.

◆ insert() [3/4]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitpacked_sequence< alphabet_type >::insert ( const_iterator  pos,
std::initializer_list< value_type > const &  ilist 
)
inline

Inserts elements from initializer list before position in the container.

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

Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.

Complexity

Worst-case linear in size().

Exceptions

Basic exception guarantee, i.e. guaranteed not to leak, but container may contain invalid data after exception is thrown.

This entity is stable. Since version 3.1.

◆ insert() [4/4]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitpacked_sequence< alphabet_type >::insert ( const_iterator  pos,
value_type const  value 
)
inline

Inserts value before position in the container.

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

Causes reallocation if the new size() is greater than the old capacity(). If the new size() is greater than capacity(), all iterators and references are invalidated. Otherwise, only the iterators and references before the insertion point remain valid. The past-the-end iterator is also invalidated.

Complexity

Worst-case linear in size().

Exceptions

Basic exception guarantee, i.e. guaranteed not to leak, but container may contain invalid data after exception is thrown.

This entity is stable. Since version 3.1.

◆ max_size()

template<writable_semialphabet alphabet_type>
size_type seqan3::bitpacked_sequence< alphabet_type >::max_size ( ) const
inlinenoexcept

Returns the maximum number of elements the container is able to hold due to system or library implementation limitations, i.e. std::distance(begin(), end()) for the largest container.

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.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ operator!=()

template<writable_semialphabet alphabet_type>
constexpr bool seqan3::bitpacked_sequence< alphabet_type >::operator!= ( bitpacked_sequence< alphabet_type > const &  rhs) const
inlineconstexprnoexcept

Checks whether *this is not equal to rhs.

This entity is stable. Since version 3.1.

◆ operator<()

template<writable_semialphabet alphabet_type>
constexpr bool seqan3::bitpacked_sequence< alphabet_type >::operator< ( bitpacked_sequence< alphabet_type > const &  rhs) const
inlineconstexprnoexcept

Checks whether *this is less than rhs.

This entity is stable. Since version 3.1.

◆ operator<=()

template<writable_semialphabet alphabet_type>
constexpr bool seqan3::bitpacked_sequence< alphabet_type >::operator<= ( bitpacked_sequence< alphabet_type > const &  rhs) const
inlineconstexprnoexcept

Checks whether *this is less than or equal to rhs.

This entity is stable. Since version 3.1.

◆ operator=()

template<writable_semialphabet alphabet_type>
bitpacked_sequence & seqan3::bitpacked_sequence< alphabet_type >::operator= ( std::initializer_list< value_type ilist)
inline

Assign from std::initializer_list.

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

Complexity

Linear in the size of ilist.

Exceptions

Strong exception guarantee (no data is modified in case an exception is thrown).

This entity is stable. Since version 3.1.

◆ operator==()

template<writable_semialphabet alphabet_type>
constexpr bool seqan3::bitpacked_sequence< alphabet_type >::operator== ( bitpacked_sequence< alphabet_type > const &  rhs) const
inlineconstexprnoexcept

Checks whether *this is equal to rhs.

This entity is stable. Since version 3.1.

◆ operator>()

template<writable_semialphabet alphabet_type>
constexpr bool seqan3::bitpacked_sequence< alphabet_type >::operator> ( bitpacked_sequence< alphabet_type > const &  rhs) const
inlineconstexprnoexcept

Checks whether *this is greater than rhs.

This entity is stable. Since version 3.1.

◆ operator>=()

template<writable_semialphabet alphabet_type>
constexpr bool seqan3::bitpacked_sequence< alphabet_type >::operator>= ( bitpacked_sequence< alphabet_type > const &  rhs) const
inlineconstexprnoexcept

Checks whether *this is greater than or equal to rhs.

This entity is stable. Since version 3.1.

◆ operator[]() [1/2]

template<writable_semialphabet alphabet_type>
const_reference seqan3::bitpacked_sequence< alphabet_type >::operator[] ( size_type const  i) const
inlinenoexcept

Return the i-th element.

Parameters
iThe element to retrieve.
Returns
Either a writable proxy to the element or a copy (if called in const context).

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

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ operator[]() [2/2]

template<writable_semialphabet alphabet_type>
reference seqan3::bitpacked_sequence< alphabet_type >::operator[] ( size_type const  i)
inlinenoexcept

Return the i-th element.

Parameters
iThe element to retrieve.
Returns
Either a writable proxy to the element or a copy (if called in const context).

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

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ pop_back()

template<writable_semialphabet alphabet_type>
void seqan3::bitpacked_sequence< alphabet_type >::pop_back ( )
inline

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 exception is thrown in release mode.

Strong exception guarantee (no data is modified in case an exception is thrown).

This entity is stable. Since version 3.1.

◆ push_back()

template<writable_semialphabet alphabet_type>
void seqan3::bitpacked_sequence< alphabet_type >::push_back ( value_type const  value)
inline

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

Parameters
valueThe value to append.

If the new size() is greater than capacity() then all iterators and references (including the past-the-end iterator) are invalidated. Otherwise only the past-the-end iterator is invalidated.

Complexity

Amortised constant, worst-case linear in size().

Exceptions

Basic exception guarantee, i.e. guaranteed not to leak, but container may contain invalid data after exception is thrown.

This entity is stable. Since version 3.1.

◆ raw_data() [1/2]

template<writable_semialphabet alphabet_type>
constexpr data_type const & seqan3::bitpacked_sequence< alphabet_type >::raw_data ( ) const
inlineconstexprnoexcept

Provides direct, unsafe access to underlying data structures.

Returns
A reference to an SDSL bitvector.

The exact representation of the data is implementation defined. Do not rely on it for API stability.

This entity is not part of the SeqAn API. Do not rely on it in your applications.

◆ raw_data() [2/2]

template<writable_semialphabet alphabet_type>
constexpr data_type & seqan3::bitpacked_sequence< alphabet_type >::raw_data ( )
inlineconstexprnoexcept

Provides direct, unsafe access to underlying data structures.

Returns
A reference to an SDSL bitvector.

The exact representation of the data is implementation defined. Do not rely on it for API stability.

This entity is not part of the SeqAn API. Do not rely on it in your applications.

◆ reserve()

template<writable_semialphabet alphabet_type>
void seqan3::bitpacked_sequence< alphabet_type >::reserve ( size_type const  new_cap)
inline

Increase the capacity to a value that's greater or equal to new_cap.

Parameters
new_capThe new capacity.
Exceptions
std::length_errorIf new_cap > max_size().
std::exceptionAny exception thrown by Allocator::allocate() (typically std::bad_alloc).

Increase the capacity of the vector to a value that's greater or equal to new_cap. If new_cap is greater than the current capacity(), new storage is allocated, otherwise the method does nothing. If new_cap is greater than capacity(), all iterators, including the past-the-end iterator, and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated.

Complexity

At most linear in the size() of the container.

Exceptions

Strong exception guarantee (no data is modified in case an exception is thrown).

This entity is stable. Since version 3.1.

◆ resize() [1/2]

template<writable_semialphabet alphabet_type>
void seqan3::bitpacked_sequence< alphabet_type >::resize ( size_type const  count)
inline

Resizes the container to contain count elements.

Parameters
countThe new size.
Exceptions
std::length_errorIf count > max_size().
std::exceptionAny exception thrown by Allocator::allocate() (typically std::bad_alloc).

Increase the size() of the vector to count.

If the current capacity() is smaller than count, new storage is allocated and all iterators, including the past-the-end iterator, and all references to the elements are invalidated. Otherwise only the past-the-end iterator is invalidated.

If the current size is greater than count, the container is reduced to its first count elements. Capacity is never reduced when resizing to smaller size because that would invalidate all iterators, rather than only the ones that would be invalidated by the equivalent sequence of pop_back() calls.

Complexity

At most linear in the size() of the container.

Exceptions

Only new size: Strong exception guarantee (no data is modified in case an exception is thrown).

New default value: Basic exception guarantee, i.e. guaranteed not to leak, but container my contain bogus data after exceptions is thrown.

This entity is stable. Since version 3.1.

◆ resize() [2/2]

template<writable_semialphabet alphabet_type>
void seqan3::bitpacked_sequence< alphabet_type >::resize ( size_type const  count,
value_type const  value 
)
inline

Resizes the container to contain count elements.

Parameters
valueAppend copies of value when resizing.
countThe new size.
Exceptions
std::length_errorIf count > max_size().
std::exceptionAny exception thrown by Allocator::allocate() (typically std::bad_alloc).

Increase the size() of the vector to count.

If the current capacity() is smaller than count, new storage is allocated and all iterators, including the past-the-end iterator, and all references to the elements are invalidated. Otherwise only the past-the-end iterator is invalidated.

If the current size is greater than count, the container is reduced to its first count elements. Capacity is never reduced when resizing to smaller size because that would invalidate all iterators, rather than only the ones that would be invalidated by the equivalent sequence of pop_back() calls.

Complexity

At most linear in the size() of the container.

Exceptions

Only new size: Strong exception guarantee (no data is modified in case an exception is thrown).

New default value: Basic exception guarantee, i.e. guaranteed not to leak, but container my contain bogus data after exceptions is thrown.

This entity is stable. Since version 3.1.

◆ shrink_to_fit()

template<writable_semialphabet alphabet_type>
void seqan3::bitpacked_sequence< alphabet_type >::shrink_to_fit ( )
inline

Requests the removal of unused capacity.

It is a non-binding request to reduce capacity() to size(). It depends on the implementation if the request is fulfilled. If reallocation occurs, all iterators, including the past the end iterator, and all references to the elements are invalidated. If no reallocation takes place, no iterators or references are invalidated.

Complexity

At most linear in the size() of the container.

Exceptions

Strong exception guarantee (no data is modified in case an exception is thrown).

This entity is stable. Since version 3.1.

◆ size()

template<writable_semialphabet alphabet_type>
size_type seqan3::bitpacked_sequence< alphabet_type >::size ( ) const
inlinenoexcept

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 stable. Since version 3.1.

◆ swap() [1/2]

template<writable_semialphabet alphabet_type>
constexpr void seqan3::bitpacked_sequence< alphabet_type >::swap ( bitpacked_sequence< alphabet_type > &&  rhs)
inlineconstexprnoexcept

Swap contents with another instance.

Parameters
rhsThe other instance to swap with.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

◆ swap() [2/2]

template<writable_semialphabet alphabet_type>
constexpr void seqan3::bitpacked_sequence< alphabet_type >::swap ( bitpacked_sequence< alphabet_type > &  rhs)
inlineconstexprnoexcept

Swap contents with another instance.

Parameters
rhsThe other instance to swap with.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.

Friends And Related Symbol Documentation

◆ swap

template<writable_semialphabet alphabet_type>
constexpr void swap ( bitpacked_sequence< alphabet_type > &  lhs,
bitpacked_sequence< alphabet_type > &  rhs 
)
friend

Swap contents with another instance.

Parameters
lhsThe first instance.
rhsThe other instance to swap with.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is stable. Since version 3.1.


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