BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
bio::ranges::bitcompressed_vector< alphabet_type > Class Template Reference

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

#include <bio/ranges/container/bitcompressed_vector.hpp>

+ Inheritance diagram for bio::ranges::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 = 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
 bitcompressed_vector ()=default
 Defaulted.
 
constexpr bitcompressed_vector (bitcompressed_vector const &)=default
 Defaulted.
 
constexpr bitcompressed_vector (bitcompressed_vector &&) noexcept=default
 Defaulted.
 
constexpr bitcompressed_vectoroperator= (bitcompressed_vector const &)=default
 Defaulted.
 
constexpr bitcompressed_vectoroperator= (bitcompressed_vector &&) noexcept=default
 Defaulted.
 
 ~bitcompressed_vector () noexcept=default
 Defaulted.
 
template<meta::different_from< bitcompressed_vector > other_range_t>
requires (std::ranges::input_range<other_range_t> && has_same_value_type_v<other_range_t>)
 bitcompressed_vector (other_range_t &&range)
 Construct from a different range.
 
 bitcompressed_vector (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>)
 bitcompressed_vector (begin_iterator_type begin_it, end_iterator_type end_it)
 Construct from pair of iterators.
 
 bitcompressed_vector (std::initializer_list< value_type > ilist)
 Construct from std::initializer_list.
 
bitcompressed_vectoroperator= (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_typeraw_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.
 

Friends

auto operator<=> (bitcompressed_vector const &lhs, bitcompressed_vector const &rhs) noexcept=default
 Comparison operators.
 

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 (bitcompressed_vector &rhs) noexcept
 Swap contents with another instance.
 
constexpr void swap (bitcompressed_vector &&rhs) noexcept
 Swap contents with another instance.
 
constexpr void swap (bitcompressed_vector &lhs, bitcompressed_vector &rhs) noexcept
 Swap contents with another instance.
 
constexpr void swap (bitcompressed_vector &&lhs, bitcompressed_vector &&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<alphabet::writable_semialphabet alphabet_type>
requires std::regular<alphabet_type>
class bio::ranges::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 bio::alphabet::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<bio::alphabet::dna4> uses a quarter of of the memory that std::vector<bio::alphabet::dna4> uses, because a single bio::alphabet::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 namespace bio::alphabet::literals;
std::vector<bio::alphabet::dna4> v0{"ACGT"_dna4}; // data occupies 4 bytes in memory
bio::ranges::bitcompressed_vector<bio::alphabet::dna4> v1{"ACGT"_dna4}; // data occupies 1 byte in memory
}
Provides bio::ranges::bitcompressed_vector.
A space-optimised version of std::vector that compresses multiple letters into a single byte.
Definition: bitcompressed_vector.hpp:63
Provides bio::alphabet::dna4, container aliases and string literals.
An inline namespace for alphabet literals. It exists to safely allow using namespace.
Definition: aa10li.hpp:183

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<alphabet::writable_semialphabet alphabet_type>
template<meta::different_from< bitcompressed_vector > other_range_t>
requires (std::ranges::input_range<other_range_t> && has_same_value_type_v<other_range_t>)
bio::ranges::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<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).

◆ bitcompressed_vector() [2/4]

template<alphabet::writable_semialphabet alphabet_type>
bio::ranges::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<alphabet::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>)
bio::ranges::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<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).

◆ bitcompressed_vector() [4/4]

template<alphabet::writable_semialphabet alphabet_type>
bio::ranges::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<alphabet::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 bio::ranges::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<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).

◆ assign() [2/4]

template<alphabet::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 bio::ranges::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<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).

◆ assign() [3/4]

template<alphabet::writable_semialphabet alphabet_type>
void bio::ranges::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() [4/4]

template<alphabet::writable_semialphabet alphabet_type>
void bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
reference bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
const_reference bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
const_reference bio::ranges::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.

◆ back() [2/2]

template<alphabet::writable_semialphabet alphabet_type>
reference bio::ranges::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.

◆ begin() [1/2]

template<alphabet::writable_semialphabet alphabet_type>
const_iterator bio::ranges::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.

◆ begin() [2/2]

template<alphabet::writable_semialphabet alphabet_type>
iterator bio::ranges::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.

◆ capacity()

template<alphabet::writable_semialphabet alphabet_type>
size_type bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
const_iterator bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
const_iterator bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
void bio::ranges::bitcompressed_vector< alphabet_type >::clear ( )
inlinenoexcept

Removes all elements from the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ empty()

template<alphabet::writable_semialphabet alphabet_type>
bool bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
const_iterator bio::ranges::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.

◆ end() [2/2]

template<alphabet::writable_semialphabet alphabet_type>
iterator bio::ranges::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.

◆ erase() [1/2]

template<alphabet::writable_semialphabet alphabet_type>
iterator bio::ranges::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 begin_it refers to the last element or begin_it == end_it, the end() iterator is returned.

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

This function always reallocates, so all iterators and references are invalidated.

Complexity

Linear in the new size().

Exceptions

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

◆ erase() [2/2]

template<alphabet::writable_semialphabet alphabet_type>
iterator bio::ranges::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.

This function always reallocates, so all iterators and references are invalidated.

Complexity

Linear in the new size().

Exceptions

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

◆ front() [1/2]

template<alphabet::writable_semialphabet alphabet_type>
const_reference bio::ranges::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.

◆ front() [2/2]

template<alphabet::writable_semialphabet alphabet_type>
reference bio::ranges::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.

◆ insert() [1/4]

template<alphabet::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 bio::ranges::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<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 well-defined, even if begin_it and end_it are iterators into *this.

This function always reallocates, so all iterators and references are invalidated.

Complexity

Linear in the new size().

Exceptions

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

◆ insert() [2/4]

template<alphabet::writable_semialphabet alphabet_type>
iterator bio::ranges::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.

This function always reallocates, so all iterators and references are invalidated.

Complexity

Linear in the new size().

Exceptions

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

◆ insert() [3/4]

template<alphabet::writable_semialphabet alphabet_type>
iterator bio::ranges::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.

This function always reallocates, so all iterators and references are invalidated.

Complexity

Linear in the new size().

Exceptions

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

◆ insert() [4/4]

template<alphabet::writable_semialphabet alphabet_type>
iterator bio::ranges::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.

This function always reallocates, so all iterators and references are invalidated.

Complexity

Linear in the new size().

Exceptions

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

◆ max_size()

template<alphabet::writable_semialphabet alphabet_type>
size_type bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
bitcompressed_vector & bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
const_reference bio::ranges::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.

◆ operator[]() [2/2]

template<alphabet::writable_semialphabet alphabet_type>
reference bio::ranges::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.

◆ pop_back()

template<alphabet::writable_semialphabet alphabet_type>
void bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
void bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
constexpr data_type const & bio::ranges::bitcompressed_vector< alphabet_type >::raw_data ( ) const
inlineconstexprnoexcept

Provides direct, unsafe access to underlying data structures.

Returns
A reference to a std::vector

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

◆ raw_data() [2/2]

template<alphabet::writable_semialphabet alphabet_type>
constexpr data_type & bio::ranges::bitcompressed_vector< alphabet_type >::raw_data ( )
inlineconstexprnoexcept

Provides direct, unsafe access to underlying data structures.

Returns
A reference to a std::vector

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

◆ reserve()

template<alphabet::writable_semialphabet alphabet_type>
void bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
void bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
void bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
void bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
size_type bio::ranges::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<alphabet::writable_semialphabet alphabet_type>
constexpr void bio::ranges::bitcompressed_vector< alphabet_type >::swap ( bitcompressed_vector< alphabet_type > &&  rhs)
inlineconstexprnoexcept

Swap contents with another instance.

Parameters
rhsThe other instance to swap with.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ swap() [2/2]

template<alphabet::writable_semialphabet alphabet_type>
constexpr void bio::ranges::bitcompressed_vector< alphabet_type >::swap ( bitcompressed_vector< alphabet_type > &  rhs)
inlineconstexprnoexcept

Swap contents with another instance.

Parameters
rhsThe other instance to swap with.

Complexity

Constant.

Exceptions

No-throw guarantee.

Friends And Related Function Documentation

◆ swap

template<alphabet::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.


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