E.V.E
v2023.02.15
Loading...
Searching...
No Matches
eve::algo::soa_vector< Type, Allocator > Class Template Reference

Detailed Description

template<eve::product_type Type, eve::simd_allocator Allocator = eve::aligned_allocator<unsigned char, eve::fixed<64>>>
class eve::algo::soa_vector< Type, Allocator >

SIMD-aware container for product types.

Required header: #include <eve/memory/soa_vector.hpp>

soa_vector is a container similar to std::vector but optimized to store [product types](eve::product_type) using a Structure Of Array layout compatible with SIMD processing.

Template Parameters
TypeValue type stored inside eve::soa_vector

Public Types

Member types
using value_type = Type
 Type of data stored in the container.
using iterator = decltype(views::convert(storage_type{}.data() , as<value_type>{}))
 Iterator over the stored Type.
using const_iterator = decltype(views::convert(std::declval<storage_type const>().data(), as<value_type>{}))
 Const iterator over the stored Type.
using iterator_aligned = decltype(views::convert(storage_type{}.data_aligned(), as<value_type>{}))
 Iterator over the stored Type using aligned data.
using const_iterator_aligned = decltype(views::convert(std::declval<storage_type const>().data_aligned(), as<value_type>{}))
 Const iterator over the stored Type using aligned data.
using pointer = iterator
 Pointer to a eve::algo::views::zip_iterator over fields.
using const_pointer = const_iterator
 Const pointer to a eve::algo::views::zip_iterator over fields.
using pointer_aligned = iterator_aligned
 Aligned pointer to a eve::algo::views::zip_iterator over fields.
using const_pointer_aligned = const_iterator_aligned
 Const aligned pointer to a eve::algo::views::zip_iterator over fields.
using size_type = std::size_t
 Size type.

Public Member Functions

Constructors
 soa_vector (Allocator a)
 Constructs an empty container with a custom Allocator.
 soa_vector ()
 Constructs an empty container.
 soa_vector (size_type n, Allocator a)
 Constructs the container with n default-inserted instances of Type and a custom Allocator.
 soa_vector (size_type n)
 Constructs the container with n default-inserted instances of Type.
 soa_vector (no_init_t, size_type n, Allocator a)
 Constructs the container with n default-inserted instances of Type and a custom Allocator.
 soa_vector (no_init_t, size_type n)
 Constructs the container with n default-inserted instances of Type.
 soa_vector (size_type n, value_type v, Allocator a)
 Constructs the container with n copies of elements with value value and a custom Allocator.
 soa_vector (size_type n, value_type v)
 Constructs the container with n copies of elements with value value.
 soa_vector (std::initializer_list< Type > l, Allocator a)
 Constructs the container with the contents of the initializer list l.
 soa_vector (std::initializer_list< Type > l)
 Constructs the container with the contents of the initializer list l.
Capacity
size_type size () const noexcept
 Returns the number of elements in the container.
size_type capacity () const noexcept
 Returns the number of elements that the container has currently allocated space for.
void shrink_to_fit ()
 Requests the removal of unused capacity.
bool empty () const noexcept
 Checks if the container has no elements.
void reserve (size_type n)
 Increase the capacity of the vector to a value that's greater or equal to n.
Element access
auto data_aligned ()
 Returns a zipped aligned pointer to the beginning.
auto data_aligned () const
 Returns a zipped aligned pointer to the beginning.
auto data ()
 Returns a zipped pointer to the beginning.
auto data () const
 Returns a constant zipped pointer to the beginning.
value_type get (size_type i) const
 Returns the value of the ith element of the container.
void set (size_type i, value_type const &v)
 Modify the value of the ith element of the container.
void fill (value_type v)
 Fill the soa_vector with a given value.
Iterators
auto begin_aligned () -> iterator_aligned
 Returns an aligned iterator to the beginning.
auto begin_aligned () const -> const_iterator_aligned
 Returns an aligned iterator to the beginning.
auto cbegin_aligned () const -> const_iterator_aligned
 Returns a constant aligned iterator to the beginning.
auto begin () -> iterator
 Returns an iterator to the beginning.
auto begin () const -> const_iterator
 Returns an iterator to the beginning.
auto cbegin () const -> const_iterator
 Returns a constant iterator to the beginning.
auto end () -> iterator
 Returns an iterator to the end.
auto end () const -> const_iterator
 Returns an iterator to the end.
auto cend () const -> const_iterator
 Returns a constant iterator to the end.

Friends

Comparisons and ordering
bool operator== (soa_vector const &lhs, soa_vector const &rhs)
 Checks if the contents of lhs and rhs are equal.
bool operator!= (soa_vector const &lhs, soa_vector const &rhs)
 Checks if the contents of lhs and rhs are not equal.

Modifiers

void clear ()
 Clear the contents of the container.
iterator erase (const_iterator pos)
 Removes an element from the container.
iterator erase (const_iterator f, const_iterator l)
 Removes the elements in the range [first, last).
void push_back (value_type const &value) noexcept
 Appends the given element value to the end of the container.
void pop_back () noexcept
 Removes the last element of the container.
void resize (size_type n, value_type value)
 Resizes the container to contain count elements.
void resize (size_type n)
 Resizes the current eve::soa_vector to a new size.
void swap (soa_vector &other) noexcept
 Exchanges the contents of the container with those of other.
Allocator get_allocator ()
 Retrieves an instance of the current allocator.
void swap (soa_vector &lhs, soa_vector &rhs) noexcept
 Swaps the contents of lhs and rhs by calling lhs.swap(rhs).

Member Function Documentation

◆ erase()

template<eve::product_type Type, eve::simd_allocator Allocator = eve::aligned_allocator<unsigned char, eve::fixed<64>>>
iterator eve::algo::soa_vector< Type, Allocator >::erase ( const_iterator pos)
inline

Removes an element from the container.

Has the same invalidation semantics as std::vector. end() iterator is not a valid pos.

◆ get()

template<eve::product_type Type, eve::simd_allocator Allocator = eve::aligned_allocator<unsigned char, eve::fixed<64>>>
value_type eve::algo::soa_vector< Type, Allocator >::get ( size_type i) const
inline

Returns the value of the ith element of the container.

Parameters
iIndex of the value to retrieve

◆ pop_back()

template<eve::product_type Type, eve::simd_allocator Allocator = eve::aligned_allocator<unsigned char, eve::fixed<64>>>
void eve::algo::soa_vector< Type, Allocator >::pop_back ( )
inlinenoexcept

Removes the last element of the container.

Calling pop_back on an empty container results in undefined behavior. Iterators and references to the last element, as well as the end() iterator, are invalidated.

◆ push_back()

template<eve::product_type Type, eve::simd_allocator Allocator = eve::aligned_allocator<unsigned char, eve::fixed<64>>>
void eve::algo::soa_vector< Type, Allocator >::push_back ( value_type const & value)
inlinenoexcept

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

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.

Parameters
valueValue to append

◆ reserve()

template<eve::product_type Type, eve::simd_allocator Allocator = eve::aligned_allocator<unsigned char, eve::fixed<64>>>
void eve::algo::soa_vector< Type, Allocator >::reserve ( size_type n)
inline

Increase the capacity of the vector to a value that's greater or equal to n.

If n is greater than the current capacity(), new storage is allocated and all iterators, including the past-the-end iterator, and all references to the elements are invalidated. Otherwise, the method does nothing.

Warning
reserve() does not change the size of the vector.
Parameters
nNew capacity of the eve::soa_vector

◆ resize()

template<eve::product_type Type, eve::simd_allocator Allocator = eve::aligned_allocator<unsigned char, eve::fixed<64>>>
void eve::algo::soa_vector< Type, Allocator >::resize ( size_type n,
value_type value )
inline

Resizes the container to contain count elements.

If the current size is greater than n, the container is reduced to its first n elements. If the current size is less than n, additional elements are appended. Those elements are either default-inserted or copied if value is provided.

Parameters
nnew size of the container
valuethe value to initialize the new elements with

◆ set()

template<eve::product_type Type, eve::simd_allocator Allocator = eve::aligned_allocator<unsigned char, eve::fixed<64>>>
void eve::algo::soa_vector< Type, Allocator >::set ( size_type i,
value_type const & v )
inline

Modify the value of the ith element of the container.

Parameters
iIndex of the value to write
vValue to write

◆ swap()

template<eve::product_type Type, eve::simd_allocator Allocator = eve::aligned_allocator<unsigned char, eve::fixed<64>>>
void eve::algo::soa_vector< Type, Allocator >::swap ( soa_vector< Type, Allocator > & other)
inlinenoexcept

Exchanges the contents of the container with those of other.

Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated.