SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
seqan3::bitcompressed_vector< alphabet_type > Class Template Reference

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

#include <seqan3/range/container/bitcompressed_vector.hpp>

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

Public Types

Associated types
using value_type = alphabet_type
 Equals the alphabet_type.
 
using reference = reference_proxy_type
 A proxy type that enables assignment, if the underlying data structure also provides a proxy.
 
using const_reference = alphabet_type
 Equals the alphabet_type / value_type.
 
using iterator = detail::random_access_iterator< bitcompressed_vector >
 The iterator type of this container (a random access iterator).
 
using const_iterator = detail::random_access_iterator< bitcompressed_vector const >
 The const_iterator type of this container (a random access iterator).
 
using difference_type = difference_type_t< data_type >
 A signed integer type (usually std::ptrdiff_t)
 
using size_type = size_type_t< data_type >
 An unsigned integer type (usually std::size_t)
 

Public Member Functions

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

Modifiers

void clear () noexcept
 Removes all elements from the container. More...
 
iterator insert (const_iterator pos, value_type const value)
 Inserts value before position in the container. More...
 
iterator insert (const_iterator pos, size_type const count, value_type const value)
 Inserts count copies of value before position in the container. More...
 
template<std::forward_iterator begin_iterator_type, typename end_iterator_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. More...
 
iterator insert (const_iterator pos, std::initializer_list< value_type > const &ilist)
 Inserts elements from initializer list before position in the container. More...
 
iterator erase (const_iterator begin_it, const_iterator end_it)
 Removes specified elements from the container. More...
 
iterator erase (const_iterator pos)
 Removes specified elements from the container. More...
 
void push_back (value_type const value)
 Appends the given element value to the end of the container. More...
 
void pop_back ()
 Removes the last element of the container. More...
 
void resize (size_type const count)
 Resizes the container to contain count elements. More...
 
void resize (size_type const count, value_type const value)
 Resizes the container to contain count elements. More...
 
constexpr void swap (bitcompressed_vector &rhs) noexcept
 Swap contents with another instance. More...
 
constexpr void swap (bitcompressed_vector &&rhs) noexcept
 Swap contents with another instance. More...
 
constexpr void swap (bitcompressed_vector &lhs, bitcompressed_vector &rhs) noexcept
 Swap contents with another instance. More...
 
constexpr void swap (bitcompressed_vector &&lhs, bitcompressed_vector &&rhs) noexcept
 

Detailed Description

template<writable_semialphabet alphabet_type>
class seqan3::bitcompressed_vector< 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. bitcompressed_vector<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 bitcompressed_vector.

Example

#include <vector>
int main()
{
using seqan3::operator""_dna4;
std::vector<seqan3::dna4> v0{"ACGT"_dna4}; // data occupies 4 bytes in memory
seqan3::bitcompressed_vector<seqan3::dna4> v1{"ACGT"_dna4}; // data occupies 1 byte in memory
}

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.

Constructor & Destructor Documentation

◆ bitcompressed_vector() [1/4]

template<writable_semialphabet alphabet_type>
template<std::ranges::input_range other_range_t>
seqan3::bitcompressed_vector< alphabet_type >::bitcompressed_vector ( 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<value_type_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).

◆ bitcompressed_vector() [2/4]

template<writable_semialphabet alphabet_type>
seqan3::bitcompressed_vector< alphabet_type >::bitcompressed_vector ( 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).

◆ bitcompressed_vector() [3/4]

template<writable_semialphabet alphabet_type>
template<std::forward_iterator begin_iterator_type, typename end_iterator_type >
seqan3::bitcompressed_vector< alphabet_type >::bitcompressed_vector ( 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<value_type_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).

◆ bitcompressed_vector() [4/4]

template<writable_semialphabet alphabet_type>
seqan3::bitcompressed_vector< alphabet_type >::bitcompressed_vector ( 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).

Member Function Documentation

◆ assign() [1/4]

template<writable_semialphabet alphabet_type>
template<std::ranges::input_range other_range_t>
void seqan3::bitcompressed_vector< 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<value_type_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).

◆ assign() [2/4]

template<writable_semialphabet alphabet_type>
void seqan3::bitcompressed_vector< 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).

◆ assign() [3/4]

template<writable_semialphabet alphabet_type>
template<std::forward_iterator begin_iterator_type, typename end_iterator_type >
void seqan3::bitcompressed_vector< 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<value_type_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).

◆ assign() [4/4]

template<writable_semialphabet alphabet_type>
void seqan3::bitcompressed_vector< 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).

◆ at() [1/2]

template<writable_semialphabet alphabet_type>
reference seqan3::bitcompressed_vector< 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().

◆ at() [2/2]

template<writable_semialphabet alphabet_type>
const_reference seqan3::bitcompressed_vector< 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().

◆ back() [1/2]

template<writable_semialphabet alphabet_type>
reference seqan3::bitcompressed_vector< 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.

◆ back() [2/2]

template<writable_semialphabet alphabet_type>
const_reference seqan3::bitcompressed_vector< 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.

◆ begin() [1/2]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitcompressed_vector< 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.

◆ begin() [2/2]

template<writable_semialphabet alphabet_type>
const_iterator seqan3::bitcompressed_vector< 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.

◆ capacity()

template<writable_semialphabet alphabet_type>
size_type seqan3::bitcompressed_vector< 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.
Attention

This does not operate on underlying concat container, see concat_capacity().

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ cbegin()

template<writable_semialphabet alphabet_type>
const_iterator seqan3::bitcompressed_vector< 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.

◆ cend()

template<writable_semialphabet alphabet_type>
const_iterator seqan3::bitcompressed_vector< 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.

◆ clear()

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

Removes all elements from the container.

Returns
The number of elements in the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ empty()

template<writable_semialphabet alphabet_type>
bool seqan3::bitcompressed_vector< 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.

◆ end() [1/2]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitcompressed_vector< 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.

◆ end() [2/2]

template<writable_semialphabet alphabet_type>
const_iterator seqan3::bitcompressed_vector< 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.

◆ erase() [1/2]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitcompressed_vector< 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.

◆ erase() [2/2]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitcompressed_vector< 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.

◆ front() [1/2]

template<writable_semialphabet alphabet_type>
reference seqan3::bitcompressed_vector< 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.

◆ front() [2/2]

template<writable_semialphabet alphabet_type>
const_reference seqan3::bitcompressed_vector< 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.

◆ insert() [1/4]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitcompressed_vector< 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.

◆ insert() [2/4]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitcompressed_vector< 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 concat_size(). This is a drawback over e.g. std::vector<std::vector<alphabet>>.

Exceptions

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

◆ insert() [3/4]

template<writable_semialphabet alphabet_type>
template<std::forward_iterator begin_iterator_type, typename end_iterator_type >
iterator seqan3::bitcompressed_vector< 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<value_type_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.

◆ insert() [4/4]

template<writable_semialphabet alphabet_type>
iterator seqan3::bitcompressed_vector< 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 concat_size(). This is a drawback over e.g. std::vector<std::vector<alphabet>>.

Exceptions

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

◆ max_size()

template<writable_semialphabet alphabet_type>
size_type seqan3::bitcompressed_vector< 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.

◆ operator=()

template<writable_semialphabet alphabet_type>
bitcompressed_vector& seqan3::bitcompressed_vector< 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).

◆ operator[]() [1/2]

template<writable_semialphabet alphabet_type>
reference seqan3::bitcompressed_vector< 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.

◆ operator[]() [2/2]

template<writable_semialphabet alphabet_type>
const_reference seqan3::bitcompressed_vector< 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.

◆ pop_back()

template<writable_semialphabet alphabet_type>
void seqan3::bitcompressed_vector< 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).

◆ push_back()

template<writable_semialphabet alphabet_type>
void seqan3::bitcompressed_vector< 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.

◆ raw_data() [1/2]

template<writable_semialphabet alphabet_type>
constexpr data_type& seqan3::bitcompressed_vector< alphabet_type >::raw_data ( )
inlinenoexcept

Provides direct, unsafe access to underlying data structures.

Returns
A reference to an SDSL bitvector.
Warning
This documentation item is not guaranteed to exist in future SeqAn3 releases. Do not rely on the interface in your applications.

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

◆ raw_data() [2/2]

template<writable_semialphabet alphabet_type>
constexpr data_type const& seqan3::bitcompressed_vector< alphabet_type >::raw_data ( ) const
inlinenoexcept

Provides direct, unsafe access to underlying data structures.

Returns
A reference to an SDSL bitvector.
Warning
This documentation item is not guaranteed to exist in future SeqAn3 releases. Do not rely on the interface in your applications.

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

◆ reserve()

template<writable_semialphabet alphabet_type>
void seqan3::bitcompressed_vector< 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).

◆ resize() [1/2]

template<writable_semialphabet alphabet_type>
void seqan3::bitcompressed_vector< 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.

◆ resize() [2/2]

template<writable_semialphabet alphabet_type>
void seqan3::bitcompressed_vector< 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.

◆ shrink_to_fit()

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

Requests the removal of unused capacity.

It is a non-binding request to reduce capacity() to size() and concat_capacity() to concat_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).

◆ size()

template<writable_semialphabet alphabet_type>
size_type seqan3::bitcompressed_vector< 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.

◆ swap() [1/2]

template<writable_semialphabet alphabet_type>
constexpr void seqan3::bitcompressed_vector< alphabet_type >::swap ( bitcompressed_vector< alphabet_type > &  rhs)
inlinenoexcept

Swap contents with another instance.

Parameters
rhsThe other instance to swap with.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ swap() [2/2]

template<writable_semialphabet alphabet_type>
constexpr void seqan3::bitcompressed_vector< alphabet_type >::swap ( bitcompressed_vector< alphabet_type > &&  rhs)
inlinenoexcept

Swap contents with another instance.

Parameters
rhsThe other instance to swap with.

Complexity

Constant.

Exceptions

No-throw guarantee.

Friends And Related Function Documentation

◆ swap [1/2]

template<writable_semialphabet alphabet_type>
constexpr void swap ( bitcompressed_vector< alphabet_type > &  lhs,
bitcompressed_vector< 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.

◆ swap [2/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.


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