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

A constexpr vector implementation with dynamic size at compile time. More...

#include <seqan3/utility/container/small_vector.hpp>

+ Inheritance diagram for seqan3::small_vector< value_type_, capacity_ >:

Public Types

Associated types
using value_type = value_type_
 The value_type type.
 
using reference = value_type &
 The reference type.
 
using const_reference = value_type const &
 The const_reference type.
 
using iterator = value_type *
 The iterator type.
 
using const_iterator = value_type const *
 The const_iterator type.
 
using difference_type = ptrdiff_t
 The difference_type type.
 
using size_type = detail::min_viable_uint_t< capacity_ >
 The size_type type.
 

Public Member Functions

Constructors, destructor and assignment
constexpr small_vector () noexcept=default
 Defaulted.
 
constexpr small_vector (small_vector const &) noexcept=default
 Defaulted.
 
constexpr small_vector (small_vector &&) noexcept=default
 Defaulted.
 
constexpr small_vectoroperator= (small_vector const &) noexcept=default
 Defaulted.
 
constexpr small_vectoroperator= (small_vector &&) noexcept=default
 Defaulted.
 
 ~small_vector () noexcept=default
 Defaulted.
 
constexpr small_vector (std::array< value_type, capacity_ > const &array) noexcept(is_noexcept)
 Construct from an (smaller or equally sized) array over the same value type.
 
template<size_t capacity2>
constexpr small_vector (value_type const (&array)[capacity2]) noexcept(is_noexcept)
 Construct from a (smaller or equally sized) built in array over the same value type.
 
template<typename... other_value_type>
requires (std::same_as<value_type, other_value_type> && ...)
constexpr small_vector (other_value_type... args) noexcept(is_noexcept)
 Construct from a list of values of value_type.
 
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr small_vector (begin_it_type begin_it, end_it_type end_it) noexcept(is_noexcept)
 Construct from two iterators.
 
template<std::ranges::input_range other_range_t>
requires (!std::is_same_v<std::remove_cvref_t<other_range_t>, small_vector>) && std::constructible_from<value_type, std::ranges::range_reference_t<other_range_t>>
constexpr small_vector (other_range_t &&range) noexcept(is_noexcept)
 Construct from a different range.
 
constexpr small_vector (size_type n, value_type value) noexcept(is_noexcept)
 Construct with n times value.
 
constexpr small_vectoroperator= (std::initializer_list< value_type > ilist) noexcept(is_noexcept)
 Assign from std::initializer_list.
 
constexpr void assign (std::initializer_list< value_type > ilist) noexcept(is_noexcept)
 Assign from std::initializer_list.
 
constexpr void assign (size_type const count, value_type const value) noexcept(is_noexcept)
 Assign with count times value.
 
template<std::ranges::input_range other_range_t>
requires std::constructible_from<value_type, std::ranges::range_reference_t<other_range_t>>
constexpr void assign (other_range_t &&range) noexcept(is_noexcept)
 Assign from a different range.
 
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr void assign (begin_it_type begin_it, end_it_type end_it) noexcept(is_noexcept)
 Assign from pair of iterators.
 
Iterators
constexpr iterator begin () noexcept
 Returns the begin to the string.
 
constexpr const_iterator begin () const noexcept
 Returns the begin to the string.
 
constexpr const_iterator cbegin () const noexcept
 Returns the begin to the string.
 
constexpr iterator end () noexcept
 Returns iterator past the end of the vector.
 
constexpr const_iterator end () const noexcept
 Returns iterator past the end of the vector.
 
constexpr const_iterator cend () const noexcept
 Returns iterator past the end of the vector.
 
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.
 
constexpr reference operator[] (size_type const i) noexcept
 Return the i-th element.
 
constexpr const_reference operator[] (size_type const i) const noexcept
 Return the i-th element.
 
constexpr reference front () noexcept
 Return the first element. Calling front on an empty container is undefined.
 
constexpr const_reference front () const noexcept
 Return the first element. Calling front on an empty container is undefined.
 
constexpr reference back () noexcept
 Return the last element.
 
constexpr const_reference back () const noexcept
 Return the last element.
 
constexpr value_typedata () noexcept
 Direct access to the underlying array.
 
constexpr value_type const * data () const noexcept
 Direct access to the underlying array.
 
Capacity
constexpr bool empty () const noexcept
 Checks whether the container is empty.
 
constexpr size_type size () const noexcept
 Returns the number of elements in the container, i.e. std::distance(begin(), end()).
 
constexpr size_type max_size () const noexcept
 Returns the maximum number of elements the container is able to hold and resolves to capacity_.
 
constexpr size_type capacity () const noexcept
 Returns the number of elements that the container is able to hold and resolves to capacity_.
 
constexpr void reserve (size_type) const noexcept
 Since the capacity is fixed on compile time, this is a no-op.
 
constexpr void shrink_to_fit () const noexcept
 Since the capacity is fixed on compile time, this is a no-op.
 
Modifiers
constexpr void clear () noexcept
 Removes all elements from the container.
 
constexpr iterator insert (const_iterator pos, value_type const value) noexcept(is_noexcept)
 Inserts value before position in the container.
 
constexpr iterator insert (const_iterator pos, size_type const count, value_type const value) noexcept(is_noexcept)
 Inserts count copies of value before position in the container.
 
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr iterator insert (const_iterator pos, begin_it_type begin_it, end_it_type end_it) noexcept(is_noexcept)
 Inserts elements from range [begin_it, end_it) before position in the container.
 
constexpr iterator insert (const_iterator pos, std::initializer_list< value_type > const &ilist) noexcept(is_noexcept)
 Inserts elements from initializer list before position in the container.
 
constexpr iterator erase (const_iterator begin_it, const_iterator end_it) noexcept
 Removes specified elements from the container.
 
constexpr iterator erase (const_iterator pos) noexcept
 Removes specified elements from the container.
 
constexpr void push_back (value_type const value) noexcept
 Appends the given element value to the end of the container.
 
constexpr void pop_back () noexcept
 Removes the last element of the container.
 
constexpr void resize (size_type const count) noexcept
 Resizes the container to contain count elements.
 
constexpr void resize (size_type const count, value_type const value) noexcept
 Resizes the container to contain count elements.
 
constexpr void swap (small_vector &rhs) noexcept(is_noexcept)
 Swap contents with another instance.
 
constexpr void swap (small_vector &&rhs) noexcept(is_noexcept)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Friends

constexpr void swap (small_vector &&lhs, small_vector &&rhs) noexcept(is_noexcept)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
constexpr void swap (small_vector &lhs, small_vector &rhs) noexcept(is_noexcept)
 Swap contents with another instance.
 
Comparison operators
template<size_t cap2>
constexpr bool operator== (small_vector const &lhs, small_vector< value_type, cap2 > const &rhs) noexcept
 Performs element-wise comparison.
 
template<size_t cap2>
constexpr bool operator!= (small_vector const &lhs, small_vector< value_type, cap2 > const &rhs) noexcept
 Performs element-wise comparison.
 
template<size_t cap2>
constexpr bool operator< (small_vector const &lhs, small_vector< value_type, cap2 > const &rhs) noexcept
 Performs element-wise comparison.
 
template<size_t cap2>
constexpr bool operator> (small_vector const &lhs, small_vector< value_type, cap2 > const &rhs) noexcept
 Performs element-wise comparison.
 
template<size_t cap2>
constexpr bool operator<= (small_vector const &lhs, small_vector< value_type, cap2 > const &rhs) noexcept
 Performs element-wise comparison.
 
template<size_t cap2>
constexpr bool operator>= (small_vector const &lhs, small_vector< value_type, cap2 > const &rhs) noexcept
 Performs element-wise comparison.
 

Detailed Description

template<typename value_type_, size_t capacity_>
class seqan3::small_vector< value_type_, capacity_ >

A constexpr vector implementation with dynamic size at compile time.

Template Parameters
value_type_The underlying value type stored in the vector.
capacity_The capacity of the constexpr vector.

This implementation of a vector can be constructed, accessed and modified at compile time. It has a fixed capacity but a dynamic size and provides all functionality of a sequence container. Note that it also models a reservable sequence container but all associated member functions are no-op because the capacity is fixed.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

Member Typedef Documentation

◆ const_iterator

template<typename value_type_ , size_t capacity_>
using seqan3::small_vector< value_type_, capacity_ >::const_iterator = value_type const *

The const_iterator type.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ const_reference

template<typename value_type_ , size_t capacity_>
using seqan3::small_vector< value_type_, capacity_ >::const_reference = value_type const &

The const_reference type.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ difference_type

template<typename value_type_ , size_t capacity_>
using seqan3::small_vector< value_type_, capacity_ >::difference_type = ptrdiff_t

The difference_type type.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ iterator

template<typename value_type_ , size_t capacity_>
using seqan3::small_vector< value_type_, capacity_ >::iterator = value_type *

The iterator type.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ reference

template<typename value_type_ , size_t capacity_>
using seqan3::small_vector< value_type_, capacity_ >::reference = value_type &

The reference type.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ size_type

template<typename value_type_ , size_t capacity_>
using seqan3::small_vector< value_type_, capacity_ >::size_type = detail::min_viable_uint_t<capacity_>

The size_type type.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ value_type

template<typename value_type_ , size_t capacity_>
using seqan3::small_vector< value_type_, capacity_ >::value_type = value_type_

The value_type type.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

Constructor & Destructor Documentation

◆ small_vector() [1/6]

template<typename value_type_ , size_t capacity_>
constexpr seqan3::small_vector< value_type_, capacity_ >::small_vector ( std::array< value_type, capacity_ > const &  array)
inlineexplicitconstexprnoexcept

Construct from an (smaller or equally sized) array over the same value type.

Parameters
[in]arrayThe array to copy the data_ from.

Complexity

Linear in the size of array.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ small_vector() [2/6]

template<typename value_type_ , size_t capacity_>
template<size_t capacity2>
constexpr seqan3::small_vector< value_type_, capacity_ >::small_vector ( value_type const (&)  array[capacity2])
inlineexplicitconstexprnoexcept

Construct from a (smaller or equally sized) built in array over the same value type.

Parameters
[in]arrayThe array to copy the data_ from.

Complexity

Linear in capacity_.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ small_vector() [3/6]

template<typename value_type_ , size_t capacity_>
template<typename... other_value_type>
requires (std::same_as<value_type, other_value_type> && ...)
constexpr seqan3::small_vector< value_type_, capacity_ >::small_vector ( other_value_type...  args)
inlineconstexprnoexcept

Construct from a list of values of value_type.

Template Parameters
other_value_typeA parameter pack where each type is equal to value_type.
Parameters
[in]argsThe values to construct from.

Complexity

Linear in the number of elements.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ small_vector() [4/6]

template<typename value_type_ , size_t capacity_>
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr seqan3::small_vector< value_type_, capacity_ >::small_vector ( begin_it_type  begin_it,
end_it_type  end_it 
)
inlineconstexprnoexcept

Construct from two iterators.

Template Parameters
begin_it_typeMust model std::forward_iterator and value_type must be constructible from the reference type of begin_it_type.
end_it_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

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ small_vector() [5/6]

template<typename value_type_ , size_t capacity_>
template<std::ranges::input_range other_range_t>
requires (!std::is_same_v<std::remove_cvref_t<other_range_t>, small_vector>) && std::constructible_from<value_type, std::ranges::range_reference_t<other_range_t>>
constexpr seqan3::small_vector< value_type_, capacity_ >::small_vector ( other_range_t &&  range)
inlineexplicitconstexprnoexcept

Construct from a different range.

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

Complexity

Linear in the size of range.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

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

◆ small_vector() [6/6]

template<typename value_type_ , size_t capacity_>
constexpr seqan3::small_vector< value_type_, capacity_ >::small_vector ( size_type  n,
value_type  value 
)
inlineconstexprnoexcept

Construct with n times value.

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

Complexity

Linear in n.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

Member Function Documentation

◆ assign() [1/4]

template<typename value_type_ , size_t capacity_>
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr void seqan3::small_vector< value_type_, capacity_ >::assign ( begin_it_type  begin_it,
end_it_type  end_it 
)
inlineconstexprnoexcept

Assign from pair of iterators.

Template Parameters
begin_it_typeMust satisfy std::forward_iterator and the value_type must be constructible from the reference type of begin_it_type.
end_it_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

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ assign() [2/4]

template<typename value_type_ , size_t capacity_>
template<std::ranges::input_range other_range_t>
requires std::constructible_from<value_type, std::ranges::range_reference_t<other_range_t>>
constexpr void seqan3::small_vector< value_type_, capacity_ >::assign ( other_range_t &&  range)
inlineconstexprnoexcept

Assign from a different range.

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

Complexity

Linear in the size of range.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

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<typename value_type_ , size_t capacity_>
constexpr void seqan3::small_vector< value_type_, capacity_ >::assign ( size_type const  count,
value_type const  value 
)
inlineconstexprnoexcept

Assign with count times value.

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

Complexity

In \(O(count)\).

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ assign() [4/4]

template<typename value_type_ , size_t capacity_>
constexpr void seqan3::small_vector< value_type_, capacity_ >::assign ( std::initializer_list< value_type ilist)
inlineconstexprnoexcept

Assign from std::initializer_list.

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

Complexity

Linear in the size of ilist.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ at() [1/2]

template<typename value_type_ , size_t capacity_>
reference seqan3::small_vector< value_type_, capacity_ >::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
A reference to the value at position i.
Attention
This is the only function of this class that is not constexpr because it might throw.

Complexity

Constant.

Exceptions

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

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ at() [2/2]

template<typename value_type_ , size_t capacity_>
const_reference seqan3::small_vector< value_type_, capacity_ >::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
A reference to the value at position i.
Attention
This is the only function of this class that is not constexpr because it might throw.

Complexity

Constant.

Exceptions

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

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ back() [1/2]

template<typename value_type_ , size_t capacity_>
constexpr const_reference seqan3::small_vector< value_type_, capacity_ >::back ( ) const
inlineconstexprnoexcept

Return the last element.

Returns
A reference to the value at the last position.

Calling back on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ back() [2/2]

template<typename value_type_ , size_t capacity_>
constexpr reference seqan3::small_vector< value_type_, capacity_ >::back ( )
inlineconstexprnoexcept

Return the last element.

Returns
A reference to the value at the last position.

Calling back on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ begin() [1/2]

template<typename value_type_ , size_t capacity_>
constexpr const_iterator seqan3::small_vector< value_type_, capacity_ >::begin ( ) const
inlineconstexprnoexcept

Returns the begin to the string.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ begin() [2/2]

template<typename value_type_ , size_t capacity_>
constexpr iterator seqan3::small_vector< value_type_, capacity_ >::begin ( )
inlineconstexprnoexcept

Returns the begin to the string.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ capacity()

template<typename value_type_ , size_t capacity_>
constexpr size_type seqan3::small_vector< value_type_, capacity_ >::capacity ( ) const
inlineconstexprnoexcept

Returns the number of elements that the container is able to hold and resolves to capacity_.

Returns
The capacity of the currently allocated storage.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ cbegin()

template<typename value_type_ , size_t capacity_>
constexpr const_iterator seqan3::small_vector< value_type_, capacity_ >::cbegin ( ) const
inlineconstexprnoexcept

Returns the begin to the string.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ cend()

template<typename value_type_ , size_t capacity_>
constexpr const_iterator seqan3::small_vector< value_type_, capacity_ >::cend ( ) const
inlineconstexprnoexcept

Returns iterator past the end of the vector.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ clear()

template<typename value_type_ , size_t capacity_>
constexpr void seqan3::small_vector< value_type_, capacity_ >::clear ( )
inlineconstexprnoexcept

Removes all elements from the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ data() [1/2]

template<typename value_type_ , size_t capacity_>
constexpr value_type const * seqan3::small_vector< value_type_, capacity_ >::data ( ) const
inlineconstexprnoexcept

Direct access to the underlying array.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ data() [2/2]

template<typename value_type_ , size_t capacity_>
constexpr value_type * seqan3::small_vector< value_type_, capacity_ >::data ( )
inlineconstexprnoexcept

Direct access to the underlying array.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ empty()

template<typename value_type_ , size_t capacity_>
constexpr bool seqan3::small_vector< value_type_, capacity_ >::empty ( ) const
inlineconstexprnoexcept

Checks whether the container is empty.

Returns
true if the container is empty, false otherwise.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ end() [1/2]

template<typename value_type_ , size_t capacity_>
constexpr const_iterator seqan3::small_vector< value_type_, capacity_ >::end ( ) const
inlineconstexprnoexcept

Returns iterator past the end of the vector.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ end() [2/2]

template<typename value_type_ , size_t capacity_>
constexpr iterator seqan3::small_vector< value_type_, capacity_ >::end ( )
inlineconstexprnoexcept

Returns iterator past the end of the vector.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ erase() [1/2]

template<typename value_type_ , size_t capacity_>
constexpr iterator seqan3::small_vector< value_type_, capacity_ >::erase ( const_iterator  begin_it,
const_iterator  end_it 
)
inlineconstexprnoexcept

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

Complexity

Linear in size().

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ erase() [2/2]

template<typename value_type_ , size_t capacity_>
constexpr iterator seqan3::small_vector< value_type_, capacity_ >::erase ( const_iterator  pos)
inlineconstexprnoexcept

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

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ front() [1/2]

template<typename value_type_ , size_t capacity_>
constexpr const_reference seqan3::small_vector< value_type_, capacity_ >::front ( ) const
inlineconstexprnoexcept

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

Returns
A reference to the value at the first position.

Calling front on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ front() [2/2]

template<typename value_type_ , size_t capacity_>
constexpr reference seqan3::small_vector< value_type_, capacity_ >::front ( )
inlineconstexprnoexcept

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

Returns
A reference to the value at the first position.

Calling front on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ insert() [1/4]

template<typename value_type_ , size_t capacity_>
template<std::forward_iterator begin_it_type, typename end_it_type >
requires std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>
constexpr iterator seqan3::small_vector< value_type_, capacity_ >::insert ( const_iterator  pos,
begin_it_type  begin_it,
end_it_type  end_it 
)
inlineconstexprnoexcept

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

Template Parameters
begin_it_typeMust satisfy std::forward_iterator and the value_type must be constructible from the reference type of begin_it_type.
end_it_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 or if, given the size n of the range represented by [begin_t, end_it), size() + n > capacity().

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ insert() [2/4]

template<typename value_type_ , size_t capacity_>
constexpr iterator seqan3::small_vector< value_type_, capacity_ >::insert ( const_iterator  pos,
size_type const  count,
value_type const  value 
)
inlineconstexprnoexcept

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.

If size() + count > capacity() this function results in undefined behaviour.

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ insert() [3/4]

template<typename value_type_ , size_t capacity_>
constexpr iterator seqan3::small_vector< value_type_, capacity_ >::insert ( const_iterator  pos,
std::initializer_list< value_type > const &  ilist 
)
inlineconstexprnoexcept

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.

Given the size n of ilist, this function results in undefined behaviour if size() + n > capacity().

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ insert() [4/4]

template<typename value_type_ , size_t capacity_>
constexpr iterator seqan3::small_vector< value_type_, capacity_ >::insert ( const_iterator  pos,
value_type const  value 
)
inlineconstexprnoexcept

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.

Inserting a value although the maximum capacity is reached is undefined behaviour.

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ max_size()

template<typename value_type_ , size_t capacity_>
constexpr size_type seqan3::small_vector< value_type_, capacity_ >::max_size ( ) const
inlineconstexprnoexcept

Returns the maximum number of elements the container is able to hold and resolves to capacity_.

Returns
The number of elements in the container.

This value typically reflects the theoretical limit on the size of the container. At runtime, the size of the container may be limited to a value smaller than max_size() by the amount of RAM available.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator=()

template<typename value_type_ , size_t capacity_>
constexpr small_vector & seqan3::small_vector< value_type_, capacity_ >::operator= ( std::initializer_list< value_type ilist)
inlineconstexprnoexcept

Assign from std::initializer_list.

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

Complexity

Linear in the size of ilist.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator[]() [1/2]

template<typename value_type_ , size_t capacity_>
constexpr const_reference seqan3::small_vector< value_type_, capacity_ >::operator[] ( size_type const  i) const
inlineconstexprnoexcept

Return the i-th element.

Parameters
iThe element to retrieve.
Returns
A reference to the value at position i.

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

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator[]() [2/2]

template<typename value_type_ , size_t capacity_>
constexpr reference seqan3::small_vector< value_type_, capacity_ >::operator[] ( size_type const  i)
inlineconstexprnoexcept

Return the i-th element.

Parameters
iThe element to retrieve.
Returns
A reference to the value at position i.

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

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ pop_back()

template<typename value_type_ , size_t capacity_>
constexpr void seqan3::small_vector< value_type_, capacity_ >::pop_back ( )
inlineconstexprnoexcept

Removes the last element of the container.

Calling pop_back() on an empty container is undefined. In debug mode an assertion will be thrown.

No iterators or references except for back() and end() are invalidated.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ push_back()

template<typename value_type_ , size_t capacity_>
constexpr void seqan3::small_vector< value_type_, capacity_ >::push_back ( value_type const  value)
inlineconstexprnoexcept

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

Parameters
valueThe value to append.

If the new size() is greater than capacity() this is undefined behaviour.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ reserve()

template<typename value_type_ , size_t capacity_>
constexpr void seqan3::small_vector< value_type_, capacity_ >::reserve ( size_type  ) const
inlineconstexprnoexcept

Since the capacity is fixed on compile time, this is a no-op.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ resize() [1/2]

template<typename value_type_ , size_t capacity_>
constexpr void seqan3::small_vector< value_type_, capacity_ >::resize ( size_type const  count)
inlineconstexprnoexcept

Resizes the container to contain count elements.

Parameters
[in]countThe new size.

If count is greater than capacity this is undefined behaviour.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ resize() [2/2]

template<typename value_type_ , size_t capacity_>
constexpr void seqan3::small_vector< value_type_, capacity_ >::resize ( size_type const  count,
value_type const  value 
)
inlineconstexprnoexcept

Resizes the container to contain count elements.

Parameters
valueAppend copies of value when resizing.
[in]countThe new size.

If count is greater than capacity this is undefined behaviour.

Complexity

Constant.

Exceptions

No-throw guarantee.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ shrink_to_fit()

template<typename value_type_ , size_t capacity_>
constexpr void seqan3::small_vector< value_type_, capacity_ >::shrink_to_fit ( ) const
inlineconstexprnoexcept

Since the capacity is fixed on compile time, this is a no-op.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ size()

template<typename value_type_ , size_t capacity_>
constexpr size_type seqan3::small_vector< value_type_, capacity_ >::size ( ) const
inlineconstexprnoexcept

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 experimental and subject to change in the future. Experimental since version 3.1.

◆ swap()

template<typename value_type_ , size_t capacity_>
constexpr void seqan3::small_vector< value_type_, capacity_ >::swap ( small_vector< value_type_, capacity_ > &  rhs)
inlineconstexprnoexcept

Swap contents with another instance.

Parameters
rhsThe other instance to swap with.

Complexity

Linear in the size of both containers.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

Friends And Related Symbol Documentation

◆ operator!=

template<typename value_type_ , size_t capacity_>
template<size_t cap2>
constexpr bool operator!= ( small_vector< value_type_, capacity_ > const &  lhs,
small_vector< value_type, cap2 > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator<

template<typename value_type_ , size_t capacity_>
template<size_t cap2>
constexpr bool operator< ( small_vector< value_type_, capacity_ > const &  lhs,
small_vector< value_type, cap2 > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator<=

template<typename value_type_ , size_t capacity_>
template<size_t cap2>
constexpr bool operator<= ( small_vector< value_type_, capacity_ > const &  lhs,
small_vector< value_type, cap2 > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator==

template<typename value_type_ , size_t capacity_>
template<size_t cap2>
constexpr bool operator== ( small_vector< value_type_, capacity_ > const &  lhs,
small_vector< value_type, cap2 > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator>

template<typename value_type_ , size_t capacity_>
template<size_t cap2>
constexpr bool operator> ( small_vector< value_type_, capacity_ > const &  lhs,
small_vector< value_type, cap2 > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ operator>=

template<typename value_type_ , size_t capacity_>
template<size_t cap2>
constexpr bool operator>= ( small_vector< value_type_, capacity_ > const &  lhs,
small_vector< value_type, cap2 > const &  rhs 
)
friend

Performs element-wise comparison.

This entity is experimental and subject to change in the future. Experimental since version 3.1.

◆ swap

template<typename value_type_ , size_t capacity_>
constexpr void swap ( small_vector< value_type_, capacity_ > &  lhs,
small_vector< value_type_, capacity_ > &  rhs 
)
friend

Swap contents with another instance.

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

Complexity

Linear in the size of both containers.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

This entity is experimental and subject to change in the future. Experimental since version 3.1.


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