|
Visual Computing Library
devel
|
A class that holds multiple vectors of different types in a tuple, constraind to the same size. More...
#include <vclib/space/core/parallel_vector_tuple.h>
Public Member Functions | |
| void | clear () |
| Clears all enabled vectors and resets the size of the parallel vector tuple to zero. | |
| void | disableAllVectors () |
| Disables all vectors in the tuple. | |
| template<uint I> | |
| void | disableVector () |
| Disables the vector at the given index. | |
| void | enableAllVectors () |
| Enables all vectors in the tuple. | |
| template<uint I> | |
| void | enableVector () |
| Enables the vector at the given index. | |
| template<uint I> | |
| bool | isVectorEnabled () const |
| Returns whether a vector at a given index is enabled. | |
| ParallelVectorTuple () | |
| Constructs a ParallelVectorTuple with all vectors enabled. | |
| void | reserve (std::size_t size) |
| Reserves space for all enabled vectors to the given size. | |
| void | resize (std::size_t size) |
| Resizes all enabled vectors to the given size, and sets the current size of the parallel vector tuple. | |
| std::size_t | size () const |
| Returns the size of the parallel vector tuple. | |
| template<uint I> | |
| auto | span () |
| Returns a std::span to the vector at the given index. | |
| template<uint I> | |
| auto | span () const |
| Returns a const std::span to the vector at the given index. | |
Static Public Member Functions | |
| static constexpr uint | tupleSize () |
| The number of vectors in the tuple. | |
Static Public Attributes | |
| static constexpr uint | TUPLE_SIZE = std::tuple_size_v<VecTuple> |
| The number of vectors in the tuple. | |
Private Types | |
| using | VecTuple = std::tuple< std::vector< Types >... > |
Private Member Functions | |
| template<std::size_t N> | |
| void | applyToAllEnabledVectors (auto &&func) |
Private Attributes | |
| std::size_t | mSize = 0 |
| std::array< bool, TUPLE_SIZE > | mVecEnabled |
| VecTuple | mVecTuple |
A class that holds multiple vectors of different types in a tuple, constraind to the same size.
This class is designed to hold multiple std::vector instances, each of a different type, in a tuple-like structure. The size of all vectors is constrained to be the same, and operations like resize, reserve, and clear are applied to all vectors simultaneously.
Each vector can be accessed, trough the index of its type in the template parameter pack, using the span() member function. It will allow to access to its elements.
The class also supports enabling and disabling individual vectors, which allows for selective operations on the contained vectors. Disabled vectors are not resized or reserved, and their contents are cleared when disabled.
The class stores the current size of the vectors, which changes only when resize or clear members are called. The size is not changed when enabling or disabling vectors (even when all vectors are disabled, the size remains unchanged).
|
inline |
Disables all vectors in the tuple.
All the vectors in the tuple are disabled, and their contents are cleared. The size of the parallel vector tuple remains unchanged.
|
inline |
Disables the vector at the given index.
At the end of the operation, the vectori si cleared and all the elements are removed. The size of the parallel vector tuple remains unchanged.
| I | The index of the vector to disable. |
|
inline |
Enables all vectors in the tuple.
All the vectors in the tuple are enabled, and their sizes are set to the current size of the parallel vector tuple.
|
inline |
Enables the vector at the given index.
At the end of the operation, the vector is resized to the current size of the parallel vector tuple, and its elements are initialized to their default values.
| I | The index of the vector to enable. |
|
inline |
Returns whether a vector at a given index is enabled.
| I | The index of the vector to check. |
|
inline |
Reserves space for all enabled vectors to the given size.
| [in] | size | The new size to reserve for all enabled vectors. |
|
inline |
Resizes all enabled vectors to the given size, and sets the current size of the parallel vector tuple.
| [in] | size | The new size to set for all enabled vectors. |
|
inline |
Returns the size of the parallel vector tuple.
|
inline |
Returns a std::span to the vector at the given index.
This function allows access to the elements of the vector at the specified index, throwing an exception if the vector is disabled.
| std::runtime_error | if the vector at index I is disabled. |
|
inline |
Returns a const std::span to the vector at the given index.
This function allows access to the elements of the vector at the specified index, throwing an exception if the vector is disabled.
| std::runtime_error | if the vector at index I is disabled. |