koutil
|
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_vector & | operator= (const multi_vector &other)=default |
multi_vector & | operator= (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>() |
Class representing a multi_vector.
Types | The types of elements stored in the multi_vector. |
|
private |
using koutil::container::multi_vector< Types >::const_iterator_t = iterator<true> |
using koutil::container::multi_vector< Types >::const_value_ref_t = transform_types_t<transform_types_t<types, transforms::constant_reference>, transforms::tuple> |
|
private |
using koutil::container::multi_vector< Types >::iterator_t = iterator<false> |
|
private |
|
private |
|
private |
|
private |
|
private |
using koutil::container::multi_vector< Types >::used_types = types |
using koutil::container::multi_vector< Types >::value_ref_t = transform_types_t<transform_types_t<types, transforms::reference>, transforms::tuple> |
using koutil::container::multi_vector< Types >::value_t = transform_types_t<types, transforms::tuple> |
|
default |
|
default |
|
default |
|
inline |
Constructs a multi_vector with a specified size and initial value.
count | The number of elements. |
value | The initial value for the elements. |
|
inlineexplicit |
Constructs a multi_vector with a specified size and default-initialized elements.
count | The number of elements. |
|
inline |
Returns a reference to the element at a specified position.
pos | The position of the element. |
|
inline |
Returns a const reference to the element at a specified position.
pos | The position of the element. |
|
inline |
Returns a reference to the last element.
|
inline |
Returns a const reference to the last element.
|
inline |
Returns an iterator to the beginning of the multi_vector.
|
inline |
Returns a const iterator to the beginning of the multi_vector.
|
inline |
Returns a const iterator to the beginning of the multi_vector.
|
inline |
Returns a const iterator to the end of the multi_vector.
|
inline |
Clears the multi_vector.
|
inlineprivate |
Clears all containers in the multi_vector.
I | The indices of the types to clear. |
|
inline |
Adds a new element to the end of the multi_vector.
Args | The types of the arguments. |
args | The arguments to construct the new element. |
|
inlineprivate |
Adds a new element to the end of all containers in the multi_vector.
Args | The types of the arguments. |
I | The indices of the types to emplace back. |
args | The arguments to construct the new elements. |
|
inlinenodiscard |
Checks if the multi_vector is empty.
|
inline |
Returns an iterator to the end of the multi_vector.
|
inline |
Returns a const iterator to the end of the multi_vector.
|
inline |
Erases an element at a specified position.
pos | The position of the element to erase. |
|
inlineprivate |
Erases an element at a specified position from all containers in the multi_vector.
I | The index of the type to erase. |
pos | The position of the element to erase. |
|
inline |
Returns a reference to the first element.
|
inline |
Returns a const reference to the first element.
|
inlineprivate |
Returns a tuple of references to all elements at a specified position.
I | The indices of the types to return. |
pos | The position of the elements. |
|
inlineprivate |
Returns a tuple of const references to all elements at a specified position.
I | The indices of the types to return. |
pos | The position of the elements. |
|
inline |
|
inline |
|
inlineprivate |
Returns a reference to a single element at a specified position.
I | The index of the type to return. |
pos | The position of the element. |
|
inlineprivate |
Returns a const reference to a single element at a specified position.
I | The index of the type to return. |
pos | The position of the element. |
|
inlineprivate |
Initializes the multi_vector with a specified size and value.
I | The index of the type to initialize. |
count | The number of elements. |
value | The value to initialize the elements with. |
|
inlineprivate |
Initializes the multi_vector with a specified size and default values.
I | The index of the type to initialize. |
count | The number of elements. |
|
default |
|
default |
|
inline |
Returns a reference to the element at a specified position.
pos | The position of the element. |
|
inline |
Returns a const reference to the element at a specified position.
pos | The position of the element. |
|
inline |
Removes the last element from the multi_vector.
|
inlineprivate |
Removes the last element from all containers in the multi_vector.
I | The indices of the types to pop back. |
|
inline |
Adds a new element to the end of the multi_vector.
value | The value to add. |
|
inline |
Adds a new element to the end of the multi_vector.
value | The value to add. |
|
inlineprivate |
Adds a new element to the end of all containers in the multi_vector.
Value | The type of the value to add. |
I | The indices of the types to push back. |
value | The value to add. |
|
inline |
Reserves storage for the multi_vector.
size | The amount of storage to reserve. |
|
inlineprivate |
Reserves storage for all containers in the multi_vector.
I | The indices of the types to reserve. |
size | The amount of storage to reserve. |
|
inline |
Resizes the multi_vector to a specified size.
size | The new size. |
|
inline |
Resizes the multi_vector to a specified size and initializes new elements with a specified value.
size | The new size. |
value | The value for new elements. |
|
inlineprivate |
Resizes all containers in the multi_vector.
I | The indices of the types to resize. |
size | The new size. |
|
inlineprivate |
Resizes all containers in the multi_vector and initializes new elements with a specified value.
I | The indices of the types to resize. |
size | The new size. |
value | The value for new elements. |
|
inline |
Shrinks the capacity of the multi_vector to fit its size.
|
inlineprivate |
Shrinks the capacity of all containers in the multi_vector to fit their size.
I | The indices of the types to shrink to fit. |
|
inlinenodiscard |
Returns the number of elements in the multi_vector.
|
inline |
Swaps the contents of two multi_vectors.
other | The other multi_vector. |
|
staticconstexprprivate |
|
private |