Blender  V3.3
Classes | Namespaces | Variables
BLI_virtual_array.hh File Reference
#include "BLI_any.hh"
#include "BLI_array.hh"
#include "BLI_index_mask.hh"
#include "BLI_span.hh"

Go to the source code of this file.

Classes

struct  blender::CommonVArrayInfo
 
class  blender::VArrayImpl< T >
 
class  blender::VMutableArrayImpl< T >
 
class  blender::VArrayImpl_For_Span< T >
 
class  blender::VArrayImpl_For_Span_final< T >
 
class  blender::VArrayImpl_For_ArrayContainer< Container, T >
 
class  blender::VArrayImpl_For_Single< T >
 
class  blender::VArrayImpl_For_Func< T, GetFunc >
 
class  blender::VArrayImpl_For_DerivedSpan< StructT, ElemT, GetFunc, SetFunc >
 
struct  blender::detail::VArrayAnyExtraInfo< T >
 
class  blender::VArrayCommon< T >
 
struct  blender::varray_tag::span
 
struct  blender::varray_tag::single_ref
 
struct  blender::varray_tag::single
 
class  blender::VArray< T >
 
class  blender::VMutableArray< T >
 
class  blender::VArraySpan< T >
 
class  blender::MutableVArraySpan< T >
 
class  blender::SingleAsSpan< T >
 

Namespaces

 blender
 
 blender::detail
 
 blender::varray_tag
 

Variables

template<typename T >
constexpr bool blender::is_trivial_extended_v< VArrayImpl_For_Span_final< T > > = true
 
template<typename T >
constexpr bool blender::is_trivial_extended_v< VArrayImpl_For_Single< T > > = is_trivial_extended_v<T>
 
template<typename StructT , typename ElemT , ElemT(*)(const StructT &) GetFunc, void(*)(StructT &, ElemT) SetFunc>
constexpr bool blender::is_trivial_extended_v< VArrayImpl_For_DerivedSpan< StructT, ElemT, GetFunc, SetFunc > > = true
 
template<typename T >
static constexpr bool blender::is_VArray_v = false
 
template<typename T >
static constexpr bool blender::is_VArray_v< VArray< T > > = true
 
template<typename T >
static constexpr bool blender::is_VMutableArray_v = false
 
template<typename T >
static constexpr bool blender::is_VMutableArray_v< VMutableArray< T > > = true
 

Detailed Description

A virtual array is a data structure that behaves similar to an array, but its elements are accessed through virtual methods. This improves the decoupling of a function from its callers, because it does not have to know exactly how the data is laid out in memory, or if it is stored in memory at all. It could just as well be computed on the fly.

Taking a virtual array as parameter instead of a more specific non-virtual type has some tradeoffs. Access to individual elements of the individual elements is higher due to function call overhead. On the other hand, potential callers don't have to convert the data into the specific format required for the function. This can be a costly conversion if only few of the elements are accessed in the end.

Functions taking a virtual array as input can still optimize for different data layouts. For example, they can check if the array is stored as an array internally or if it is the same element for all indices. Whether it is worth to optimize for different data layouts in a function has to be decided on a case by case basis. One should always do some benchmarking to see of the increased compile time and binary size is worth it.

Definition in file BLI_virtual_array.hh.