koutil
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Concepts
koutil::container::multi_vector< Types > Class Template Reference

Class representing a multi_vector. More...

#include <multi_vector.h>

Classes

class  iterator
 Nested iterator class for multi_vector. More...
 
class  single_vector
 
struct  single_vector_container
 

Public Types

using used_types = types
 
using value_ref_t = transform_types_t<transform_types_t<types, transforms::reference>, transforms::tuple>
 
using const_value_ref_t = transform_types_t<transform_types_t<types, transforms::constant_reference>, transforms::tuple>
 
using value_t = transform_types_t<types, transforms::tuple>
 
using iterator_t = iterator<false>
 
using const_iterator_t = iterator<true>
 

Public Member Functions

 multi_vector ()=default
 
 multi_vector (const multi_vector &)=default
 
 multi_vector (multi_vector &&)=default
 
 multi_vector (std::size_t count, const value_t &value)
 Constructs a multi_vector with a specified size and initial value.
 
 multi_vector (std::size_t count)
 Constructs a multi_vector with a specified size and default-initialized elements.
 
multi_vectoroperator= (const multi_vector &other)=default
 
multi_vectoroperator= (multi_vector &&)=default
 
template<std::size_t I>
decltype(auto) get_container ()
 
template<std::size_t I>
decltype(auto) get_container () const
 
value_ref_t front ()
 Returns a reference to the first element.
 
const_value_ref_t front () const
 Returns a const reference to the first element.
 
value_ref_t back ()
 Returns a reference to the last element.
 
const_value_ref_t back () const
 Returns a const reference to the last element.
 
value_ref_t at (std::size_t pos)
 Returns a reference to the element at a specified position.
 
const_value_ref_t at (std::size_t pos) const
 Returns a const reference to the element at a specified position.
 
value_ref_t operator[] (std::size_t pos)
 Returns a reference to the element at a specified position.
 
const_value_ref_t operator[] (std::size_t pos) const
 Returns a const reference to the element at a specified position.
 
std::size_t size () const
 Returns the number of elements in the multi_vector.
 
bool empty () const
 Checks if the multi_vector is empty.
 
void clear ()
 Clears the multi_vector.
 
void swap (multi_vector &other)
 Swaps the contents of two multi_vectors.
 
void resize (std::size_t size)
 Resizes the multi_vector to a specified size.
 
void resize (std::size_t size, const value_t &value)
 Resizes the multi_vector to a specified size and initializes new elements with a specified value.
 
void reserve (std::size_t size)
 Reserves storage for the multi_vector.
 
void pop_back ()
 Removes the last element from the multi_vector.
 
template<typename... Args>
requires (sizeof...(Args) == types::size)
value_ref_t emplace_back (Args &&... args)
 Adds a new element to the end of the multi_vector.
 
void push_back (const value_t &value)
 Adds a new element to the end of the multi_vector.
 
void push_back (value_t &&value)
 Adds a new element to the end of the multi_vector.
 
void shrink_to_fit ()
 Shrinks the capacity of the multi_vector to fit its size.
 
iterator_t erase (const_iterator_t pos)
 Erases an element at a specified position.
 
iterator_t begin ()
 Returns an iterator to the beginning of the multi_vector.
 
const_iterator_t begin () const
 Returns a const iterator to the beginning of the multi_vector.
 
const_iterator_t cbegin () const
 Returns a const iterator to the beginning of the multi_vector.
 
iterator_t end ()
 Returns an iterator to the end of the multi_vector.
 
const_iterator_t end () const
 Returns a const iterator to the end of the multi_vector.
 
const_iterator_t cend () const
 Returns a const iterator to the end of the multi_vector.
 

Private Types

using transforms = type::types_transforms
 
using containers = type::types_containers
 
template<type::types_concept T, type::types_container Container>
using to_containers_t = type::types_to_containers_t<T, Container>
 
template<type::types_concept T, type::types_transform Transform>
using transform_types_t = type::types_transform_t<T, Transform>
 
using all_types = type::types<Types...>
 
using types = type::types_remove_t<all_types, void>
 
using storage_t = transform_types_t<to_containers_t<types, single_vector_container>, transforms::tuple>
 

Private Member Functions

template<std::size_t I = 0>
void init_vector (std::size_t count, const value_t &value)
 Initializes the multi_vector with a specified size and value.
 
template<std::size_t I = 0>
void init_vector_default (std::size_t count)
 Initializes the multi_vector with a specified size and default values.
 
template<std::size_t I>
auto & get_single (std::size_t pos)
 Returns a reference to a single element at a specified position.
 
template<std::size_t I>
const auto & get_single (std::size_t pos) const
 Returns a const reference to a single element at a specified position.
 
template<std::size_t... I>
value_ref_t get_all (std::size_t pos, std::index_sequence< I... >)
 Returns a tuple of references to all elements at a specified position.
 
template<std::size_t... I>
const_value_ref_t get_all (std::size_t pos, std::index_sequence< I... >) const
 Returns a tuple of const references to all elements at a specified position.
 
template<std::size_t... I>
void clear_all (std::index_sequence< I... >)
 Clears all containers in the multi_vector.
 
template<std::size_t... I>
void resize_all (std::size_t size, std::index_sequence< I... >)
 Resizes all containers in the multi_vector.
 
template<std::size_t... I>
void resize_all_with (std::size_t size, const value_t &value, std::index_sequence< I... >)
 Resizes all containers in the multi_vector and initializes new elements with a specified value.
 
template<std::size_t... I>
void pop_back_impl (std::index_sequence< I... >)
 Removes the last element from all containers in the multi_vector.
 
template<typename Value , std::size_t... I>
void push_back_impl (Value &&value, std::index_sequence< I... >)
 Adds a new element to the end of all containers in the multi_vector.
 
template<typename... Args, std::size_t... I>
value_ref_t emplace_back_impl (std::index_sequence< I... >, Args &&... args)
 Adds a new element to the end of all containers in the multi_vector.
 
template<std::size_t... I>
void shrink_to_fit_impl (std::index_sequence< I... >)
 Shrinks the capacity of all containers in the multi_vector to fit their size.
 
template<std::size_t... I>
void reserve_impl (std::size_t size, std::index_sequence< I... >)
 Reserves storage for all containers in the multi_vector.
 
template<std::size_t I = 0>
void erase_impl (const_iterator_t pos)
 Erases an element at a specified position from all containers in the multi_vector.
 

Private Attributes

storage_t m_storage
 

Static Private Attributes

static constexpr auto helper_seq = std::make_index_sequence<types::size>()
 

Detailed Description

template<is_multi_vector_element... Types>
requires (type::types_remove_t<type::types<Types...>, void>::size != 0)
class koutil::container::multi_vector< Types >

Class representing a multi_vector.

Template Parameters
TypesThe types of elements stored in the multi_vector.

Member Typedef Documentation

◆ all_types

template<is_multi_vector_element... Types>
using koutil::container::multi_vector< Types >::all_types = type::types<Types...>
private

◆ const_iterator_t

template<is_multi_vector_element... Types>
using koutil::container::multi_vector< Types >::const_iterator_t = iterator<true>

◆ const_value_ref_t

template<is_multi_vector_element... Types>
using koutil::container::multi_vector< Types >::const_value_ref_t = transform_types_t<transform_types_t<types, transforms::constant_reference>, transforms::tuple>

◆ containers

template<is_multi_vector_element... Types>
using koutil::container::multi_vector< Types >::containers = type::types_containers
private

◆ iterator_t

template<is_multi_vector_element... Types>
using koutil::container::multi_vector< Types >::iterator_t = iterator<false>

◆ storage_t

template<is_multi_vector_element... Types>
using koutil::container::multi_vector< Types >::storage_t = transform_types_t<to_containers_t<types, single_vector_container>, transforms::tuple>
private

◆ to_containers_t

template<is_multi_vector_element... Types>
template<type::types_concept T, type::types_container Container>
using koutil::container::multi_vector< Types >::to_containers_t = type::types_to_containers_t<T, Container>
private

◆ transform_types_t

template<is_multi_vector_element... Types>
template<type::types_concept T, type::types_transform Transform>
using koutil::container::multi_vector< Types >::transform_types_t = type::types_transform_t<T, Transform>
private

◆ transforms

template<is_multi_vector_element... Types>
using koutil::container::multi_vector< Types >::transforms = type::types_transforms
private

◆ types

template<is_multi_vector_element... Types>
using koutil::container::multi_vector< Types >::types = type::types_remove_t<all_types, void>
private

◆ used_types

template<is_multi_vector_element... Types>
using koutil::container::multi_vector< Types >::used_types = types

◆ value_ref_t

template<is_multi_vector_element... Types>
using koutil::container::multi_vector< Types >::value_ref_t = transform_types_t<transform_types_t<types, transforms::reference>, transforms::tuple>

◆ value_t

template<is_multi_vector_element... Types>
using koutil::container::multi_vector< Types >::value_t = transform_types_t<types, transforms::tuple>

Constructor & Destructor Documentation

◆ multi_vector() [1/5]

template<is_multi_vector_element... Types>
koutil::container::multi_vector< Types >::multi_vector ( )
default

◆ multi_vector() [2/5]

template<is_multi_vector_element... Types>
koutil::container::multi_vector< Types >::multi_vector ( const multi_vector< Types > & )
default

◆ multi_vector() [3/5]

template<is_multi_vector_element... Types>
koutil::container::multi_vector< Types >::multi_vector ( multi_vector< Types > && )
default

◆ multi_vector() [4/5]

template<is_multi_vector_element... Types>
koutil::container::multi_vector< Types >::multi_vector ( std::size_t count,
const value_t & value )
inline

Constructs a multi_vector with a specified size and initial value.

Parameters
countThe number of elements.
valueThe initial value for the elements.

◆ multi_vector() [5/5]

template<is_multi_vector_element... Types>
koutil::container::multi_vector< Types >::multi_vector ( std::size_t count)
inlineexplicit

Constructs a multi_vector with a specified size and default-initialized elements.

Parameters
countThe number of elements.

Member Function Documentation

◆ at() [1/2]

template<is_multi_vector_element... Types>
value_ref_t koutil::container::multi_vector< Types >::at ( std::size_t pos)
inline

Returns a reference to the element at a specified position.

Parameters
posThe position of the element.
Returns
Reference to the element.

◆ at() [2/2]

template<is_multi_vector_element... Types>
const_value_ref_t koutil::container::multi_vector< Types >::at ( std::size_t pos) const
inline

Returns a const reference to the element at a specified position.

Parameters
posThe position of the element.
Returns
Const reference to the element.

◆ back() [1/2]

template<is_multi_vector_element... Types>
value_ref_t koutil::container::multi_vector< Types >::back ( )
inline

Returns a reference to the last element.

Returns
Reference to the last element.

◆ back() [2/2]

template<is_multi_vector_element... Types>
const_value_ref_t koutil::container::multi_vector< Types >::back ( ) const
inline

Returns a const reference to the last element.

Returns
Const reference to the last element.

◆ begin() [1/2]

template<is_multi_vector_element... Types>
iterator_t koutil::container::multi_vector< Types >::begin ( )
inline

Returns an iterator to the beginning of the multi_vector.

Returns
An iterator to the beginning of the multi_vector.

◆ begin() [2/2]

template<is_multi_vector_element... Types>
const_iterator_t koutil::container::multi_vector< Types >::begin ( ) const
inline

Returns a const iterator to the beginning of the multi_vector.

Returns
A const iterator to the beginning of the multi_vector.

◆ cbegin()

template<is_multi_vector_element... Types>
const_iterator_t koutil::container::multi_vector< Types >::cbegin ( ) const
inline

Returns a const iterator to the beginning of the multi_vector.

Returns
A const iterator to the beginning of the multi_vector.

◆ cend()

template<is_multi_vector_element... Types>
const_iterator_t koutil::container::multi_vector< Types >::cend ( ) const
inline

Returns a const iterator to the end of the multi_vector.

Returns
A const iterator to the end of the multi_vector.

◆ clear()

template<is_multi_vector_element... Types>
void koutil::container::multi_vector< Types >::clear ( )
inline

Clears the multi_vector.

◆ clear_all()

template<is_multi_vector_element... Types>
template<std::size_t... I>
void koutil::container::multi_vector< Types >::clear_all ( std::index_sequence< I... > )
inlineprivate

Clears all containers in the multi_vector.

Template Parameters
IThe indices of the types to clear.

◆ emplace_back()

template<is_multi_vector_element... Types>
template<typename... Args>
requires (sizeof...(Args) == types::size)
value_ref_t koutil::container::multi_vector< Types >::emplace_back ( Args &&... args)
inline

Adds a new element to the end of the multi_vector.

Template Parameters
ArgsThe types of the arguments.
Parameters
argsThe arguments to construct the new element.
Returns
A tuple of references to the newly added elements.

◆ emplace_back_impl()

template<is_multi_vector_element... Types>
template<typename... Args, std::size_t... I>
value_ref_t koutil::container::multi_vector< Types >::emplace_back_impl ( std::index_sequence< I... > ,
Args &&... args )
inlineprivate

Adds a new element to the end of all containers in the multi_vector.

Template Parameters
ArgsThe types of the arguments.
IThe indices of the types to emplace back.
Parameters
argsThe arguments to construct the new elements.
Returns
A tuple of references to the newly added elements.

◆ empty()

template<is_multi_vector_element... Types>
bool koutil::container::multi_vector< Types >::empty ( ) const
inlinenodiscard

Checks if the multi_vector is empty.

Returns
True if the multi_vector is empty, false otherwise.

◆ end() [1/2]

template<is_multi_vector_element... Types>
iterator_t koutil::container::multi_vector< Types >::end ( )
inline

Returns an iterator to the end of the multi_vector.

Returns
An iterator to the end of the multi_vector.

◆ end() [2/2]

template<is_multi_vector_element... Types>
const_iterator_t koutil::container::multi_vector< Types >::end ( ) const
inline

Returns a const iterator to the end of the multi_vector.

Returns
A const iterator to the end of the multi_vector.

◆ erase()

template<is_multi_vector_element... Types>
iterator_t koutil::container::multi_vector< Types >::erase ( const_iterator_t pos)
inline

Erases an element at a specified position.

Parameters
posThe position of the element to erase.
Returns
An iterator to the element following the erased element.

◆ erase_impl()

template<is_multi_vector_element... Types>
template<std::size_t I = 0>
void koutil::container::multi_vector< Types >::erase_impl ( const_iterator_t pos)
inlineprivate

Erases an element at a specified position from all containers in the multi_vector.

Template Parameters
IThe index of the type to erase.
Parameters
posThe position of the element to erase.

◆ front() [1/2]

template<is_multi_vector_element... Types>
value_ref_t koutil::container::multi_vector< Types >::front ( )
inline

Returns a reference to the first element.

Returns
Reference to the first element.

◆ front() [2/2]

template<is_multi_vector_element... Types>
const_value_ref_t koutil::container::multi_vector< Types >::front ( ) const
inline

Returns a const reference to the first element.

Returns
Const reference to the first element.

◆ get_all() [1/2]

template<is_multi_vector_element... Types>
template<std::size_t... I>
value_ref_t koutil::container::multi_vector< Types >::get_all ( std::size_t pos,
std::index_sequence< I... >  )
inlineprivate

Returns a tuple of references to all elements at a specified position.

Template Parameters
IThe indices of the types to return.
Parameters
posThe position of the elements.
Returns
Tuple of references to the elements.

◆ get_all() [2/2]

template<is_multi_vector_element... Types>
template<std::size_t... I>
const_value_ref_t koutil::container::multi_vector< Types >::get_all ( std::size_t pos,
std::index_sequence< I... >  ) const
inlineprivate

Returns a tuple of const references to all elements at a specified position.

Template Parameters
IThe indices of the types to return.
Parameters
posThe position of the elements.
Returns
Tuple of const references to the elements.

◆ get_container() [1/2]

template<is_multi_vector_element... Types>
template<std::size_t I>
decltype(auto) koutil::container::multi_vector< Types >::get_container ( )
inline

◆ get_container() [2/2]

template<is_multi_vector_element... Types>
template<std::size_t I>
decltype(auto) koutil::container::multi_vector< Types >::get_container ( ) const
inline

◆ get_single() [1/2]

template<is_multi_vector_element... Types>
template<std::size_t I>
auto & koutil::container::multi_vector< Types >::get_single ( std::size_t pos)
inlineprivate

Returns a reference to a single element at a specified position.

Template Parameters
IThe index of the type to return.
Parameters
posThe position of the element.
Returns
Reference to the element.

◆ get_single() [2/2]

template<is_multi_vector_element... Types>
template<std::size_t I>
const auto & koutil::container::multi_vector< Types >::get_single ( std::size_t pos) const
inlineprivate

Returns a const reference to a single element at a specified position.

Template Parameters
IThe index of the type to return.
Parameters
posThe position of the element.
Returns
Const reference to the element.

◆ init_vector()

template<is_multi_vector_element... Types>
template<std::size_t I = 0>
void koutil::container::multi_vector< Types >::init_vector ( std::size_t count,
const value_t & value )
inlineprivate

Initializes the multi_vector with a specified size and value.

Template Parameters
IThe index of the type to initialize.
Parameters
countThe number of elements.
valueThe value to initialize the elements with.

◆ init_vector_default()

template<is_multi_vector_element... Types>
template<std::size_t I = 0>
void koutil::container::multi_vector< Types >::init_vector_default ( std::size_t count)
inlineprivate

Initializes the multi_vector with a specified size and default values.

Template Parameters
IThe index of the type to initialize.
Parameters
countThe number of elements.

◆ operator=() [1/2]

template<is_multi_vector_element... Types>
multi_vector & koutil::container::multi_vector< Types >::operator= ( const multi_vector< Types > & other)
default

◆ operator=() [2/2]

template<is_multi_vector_element... Types>
multi_vector & koutil::container::multi_vector< Types >::operator= ( multi_vector< Types > && )
default

◆ operator[]() [1/2]

template<is_multi_vector_element... Types>
value_ref_t koutil::container::multi_vector< Types >::operator[] ( std::size_t pos)
inline

Returns a reference to the element at a specified position.

Parameters
posThe position of the element.
Returns
Reference to the element.

◆ operator[]() [2/2]

template<is_multi_vector_element... Types>
const_value_ref_t koutil::container::multi_vector< Types >::operator[] ( std::size_t pos) const
inline

Returns a const reference to the element at a specified position.

Parameters
posThe position of the element.
Returns
Const reference to the element.

◆ pop_back()

template<is_multi_vector_element... Types>
void koutil::container::multi_vector< Types >::pop_back ( )
inline

Removes the last element from the multi_vector.

◆ pop_back_impl()

template<is_multi_vector_element... Types>
template<std::size_t... I>
void koutil::container::multi_vector< Types >::pop_back_impl ( std::index_sequence< I... > )
inlineprivate

Removes the last element from all containers in the multi_vector.

Template Parameters
IThe indices of the types to pop back.

◆ push_back() [1/2]

template<is_multi_vector_element... Types>
void koutil::container::multi_vector< Types >::push_back ( const value_t & value)
inline

Adds a new element to the end of the multi_vector.

Parameters
valueThe value to add.

◆ push_back() [2/2]

template<is_multi_vector_element... Types>
void koutil::container::multi_vector< Types >::push_back ( value_t && value)
inline

Adds a new element to the end of the multi_vector.

Parameters
valueThe value to add.

◆ push_back_impl()

template<is_multi_vector_element... Types>
template<typename Value , std::size_t... I>
void koutil::container::multi_vector< Types >::push_back_impl ( Value && value,
std::index_sequence< I... >  )
inlineprivate

Adds a new element to the end of all containers in the multi_vector.

Template Parameters
ValueThe type of the value to add.
IThe indices of the types to push back.
Parameters
valueThe value to add.

◆ reserve()

template<is_multi_vector_element... Types>
void koutil::container::multi_vector< Types >::reserve ( std::size_t size)
inline

Reserves storage for the multi_vector.

Parameters
sizeThe amount of storage to reserve.

◆ reserve_impl()

template<is_multi_vector_element... Types>
template<std::size_t... I>
void koutil::container::multi_vector< Types >::reserve_impl ( std::size_t size,
std::index_sequence< I... >  )
inlineprivate

Reserves storage for all containers in the multi_vector.

Template Parameters
IThe indices of the types to reserve.
Parameters
sizeThe amount of storage to reserve.

◆ resize() [1/2]

template<is_multi_vector_element... Types>
void koutil::container::multi_vector< Types >::resize ( std::size_t size)
inline

Resizes the multi_vector to a specified size.

Parameters
sizeThe new size.

◆ resize() [2/2]

template<is_multi_vector_element... Types>
void koutil::container::multi_vector< Types >::resize ( std::size_t size,
const value_t & value )
inline

Resizes the multi_vector to a specified size and initializes new elements with a specified value.

Parameters
sizeThe new size.
valueThe value for new elements.

◆ resize_all()

template<is_multi_vector_element... Types>
template<std::size_t... I>
void koutil::container::multi_vector< Types >::resize_all ( std::size_t size,
std::index_sequence< I... >  )
inlineprivate

Resizes all containers in the multi_vector.

Template Parameters
IThe indices of the types to resize.
Parameters
sizeThe new size.

◆ resize_all_with()

template<is_multi_vector_element... Types>
template<std::size_t... I>
void koutil::container::multi_vector< Types >::resize_all_with ( std::size_t size,
const value_t & value,
std::index_sequence< I... >  )
inlineprivate

Resizes all containers in the multi_vector and initializes new elements with a specified value.

Template Parameters
IThe indices of the types to resize.
Parameters
sizeThe new size.
valueThe value for new elements.

◆ shrink_to_fit()

template<is_multi_vector_element... Types>
void koutil::container::multi_vector< Types >::shrink_to_fit ( )
inline

Shrinks the capacity of the multi_vector to fit its size.

◆ shrink_to_fit_impl()

template<is_multi_vector_element... Types>
template<std::size_t... I>
void koutil::container::multi_vector< Types >::shrink_to_fit_impl ( std::index_sequence< I... > )
inlineprivate

Shrinks the capacity of all containers in the multi_vector to fit their size.

Template Parameters
IThe indices of the types to shrink to fit.

◆ size()

template<is_multi_vector_element... Types>
std::size_t koutil::container::multi_vector< Types >::size ( ) const
inlinenodiscard

Returns the number of elements in the multi_vector.

Returns
The number of elements.

◆ swap()

template<is_multi_vector_element... Types>
void koutil::container::multi_vector< Types >::swap ( multi_vector< Types > & other)
inline

Swaps the contents of two multi_vectors.

Parameters
otherThe other multi_vector.

Member Data Documentation

◆ helper_seq

template<is_multi_vector_element... Types>
auto koutil::container::multi_vector< Types >::helper_seq = std::make_index_sequence<types::size>()
staticconstexprprivate

◆ m_storage

template<is_multi_vector_element... Types>
storage_t koutil::container::multi_vector< Types >::m_storage
private

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