Blender  V2.93
Public Types | Public Member Functions | Static Public Member Functions | List of all members
blender::Array< T, InlineBufferCapacity, Allocator > Class Template Reference

#include <BLI_array.hh>

Public Types

using value_type = T
 
using pointer = T *
 
using const_pointer = const T *
 
using reference = T &
 
using const_reference = const T &
 
using iterator = T *
 
using const_iterator = const T *
 
using size_type = int64_t
 

Public Member Functions

 Array (Allocator allocator={}) noexcept
 
 Array (NoExceptConstructor, Allocator allocator={}) noexcept
 
template<typename U , typename std::enable_if_t< std::is_convertible_v< U, T >> * = nullptr>
 Array (Span< U > values, Allocator allocator={})
 
template<typename U , typename std::enable_if_t< std::is_convertible_v< U, T >> * = nullptr>
 Array (const std::initializer_list< U > &values, Allocator allocator={})
 
 Array (const std::initializer_list< T > &values, Allocator allocator={})
 
 Array (int64_t size, Allocator allocator={})
 
 Array (int64_t size, const T &value, Allocator allocator={})
 
 Array (int64_t size, NoInitialization, Allocator allocator={})
 
 Array (const Array &other)
 
 Array (Array &&other) noexcept(std::is_nothrow_move_constructible_v< T >)
 
 ~Array ()
 
Arrayoperator= (const Array &other)
 
Arrayoperator= (Array &&other) noexcept(std::is_nothrow_move_constructible_v< T >)
 
Toperator[] (int64_t index)
 
const Toperator[] (int64_t index) const
 
 operator Span< T > () const
 
 operator MutableSpan< T > ()
 
template<typename U , typename std::enable_if_t< is_span_convertible_pointer_v< T, U >> * = nullptr>
 operator Span< U > () const
 
template<typename U , typename std::enable_if_t< is_span_convertible_pointer_v< T, U >> * = nullptr>
 operator MutableSpan< U > ()
 
Span< Tas_span () const
 
MutableSpan< Tas_mutable_span ()
 
int64_t size () const
 
bool is_empty () const
 
void fill (const T &value) const
 
const Tlast () const
 
Tlast ()
 
const Tdata () const
 
Tdata ()
 
const Tbegin () const
 
const Tend () const
 
Tbegin ()
 
Tend ()
 
std::reverse_iterator< T * > rbegin ()
 
std::reverse_iterator< T * > rend ()
 
std::reverse_iterator< const T * > rbegin () const
 
std::reverse_iterator< const T * > rend () const
 
IndexRange index_range () const
 
void clear_without_destruct ()
 
Allocator & allocator ()
 
const Allocator & allocator () const
 
void reinitialize (const int64_t new_size)
 

Static Public Member Functions

static int64_t inline_buffer_capacity ()
 

Detailed Description

template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
class blender::Array< T, InlineBufferCapacity, Allocator >

Definition at line 62 of file BLI_array.hh.

Member Typedef Documentation

◆ const_iterator

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::const_iterator = const T *

Definition at line 70 of file BLI_array.hh.

◆ const_pointer

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::const_pointer = const T *

Definition at line 66 of file BLI_array.hh.

◆ const_reference

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::const_reference = const T &

Definition at line 68 of file BLI_array.hh.

◆ iterator

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::iterator = T *

Definition at line 69 of file BLI_array.hh.

◆ pointer

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::pointer = T *

Definition at line 65 of file BLI_array.hh.

◆ reference

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::reference = T &

Definition at line 67 of file BLI_array.hh.

◆ size_type

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::size_type = int64_t

Definition at line 71 of file BLI_array.hh.

◆ value_type

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
using blender::Array< T, InlineBufferCapacity, Allocator >::value_type = T

Definition at line 64 of file BLI_array.hh.

Constructor & Destructor Documentation

◆ Array() [1/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( Allocator  allocator = {})
inlinenoexcept

By default an empty array is created.

Definition at line 90 of file BLI_array.hh.

◆ Array() [2/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( NoExceptConstructor  ,
Allocator  allocator = {} 
)
inlinenoexcept

Definition at line 96 of file BLI_array.hh.

◆ Array() [3/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
template<typename U , typename std::enable_if_t< std::is_convertible_v< U, T >> * = nullptr>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( Span< U values,
Allocator  allocator = {} 
)
inline

Create a new array that contains copies of all values.

Definition at line 104 of file BLI_array.hh.

◆ Array() [4/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
template<typename U , typename std::enable_if_t< std::is_convertible_v< U, T >> * = nullptr>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( const std::initializer_list< U > &  values,
Allocator  allocator = {} 
)
inline

Create a new array that contains copies of all values.

Definition at line 116 of file BLI_array.hh.

◆ Array() [5/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( const std::initializer_list< T > &  values,
Allocator  allocator = {} 
)
inline

Definition at line 121 of file BLI_array.hh.

◆ Array() [6/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( int64_t  size,
Allocator  allocator = {} 
)
inlineexplicit

Create a new array with the given size. All values will be default constructed. For trivial types like int, default construction does nothing.

We might want another version of this in the future, that does not do default construction even for non-trivial types. This should not be the default though, because one can easily mess up when dealing with uninitialized memory.

Definition at line 134 of file BLI_array.hh.

◆ Array() [7/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( int64_t  size,
const T value,
Allocator  allocator = {} 
)
inline

Create a new array with the given size. All values will be initialized by copying the given default.

Definition at line 145 of file BLI_array.hh.

◆ Array() [8/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( int64_t  size,
NoInitialization  ,
Allocator  allocator = {} 
)
inline

Create a new array with uninitialized elements. The caller is responsible for constructing the elements. Moving, copying or destructing an Array with uninitialized elements invokes undefined behavior.

This should be used very rarely. Note, that the normal size-constructor also does not initialize the elements when T is trivially constructible. Therefore, it only makes sense to use this with non trivially constructible types.

Usage: Array<std::string> my_strings(10, NoInitialization());

Definition at line 166 of file BLI_array.hh.

◆ Array() [9/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( const Array< T, InlineBufferCapacity, Allocator > &  other)
inline

Definition at line 174 of file BLI_array.hh.

◆ Array() [10/10]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::Array ( Array< T, InlineBufferCapacity, Allocator > &&  other)
inlinenoexcept

Definition at line 178 of file BLI_array.hh.

References data_, and blender::uninitialized_relocate_n().

◆ ~Array()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::~Array ( )
inline

Definition at line 193 of file BLI_array.hh.

References data_, and blender::destruct_n().

Member Function Documentation

◆ allocator() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
Allocator& blender::Array< T, InlineBufferCapacity, Allocator >::allocator ( )
inline

Access the allocator used by this array.

Definition at line 362 of file BLI_array.hh.

◆ allocator() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const Allocator& blender::Array< T, InlineBufferCapacity, Allocator >::allocator ( ) const
inline

Definition at line 366 of file BLI_array.hh.

◆ as_mutable_span()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
MutableSpan<T> blender::Array< T, InlineBufferCapacity, Allocator >::as_mutable_span ( )
inline

Definition at line 250 of file BLI_array.hh.

Referenced by blender::nodes::distribute_points_poisson_disk().

◆ as_span()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
Span<T> blender::Array< T, InlineBufferCapacity, Allocator >::as_span ( ) const
inline

◆ begin() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T* blender::Array< T, InlineBufferCapacity, Allocator >::begin ( )
inline

Definition at line 315 of file BLI_array.hh.

References data_.

◆ begin() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T* blender::Array< T, InlineBufferCapacity, Allocator >::begin ( ) const
inline

Definition at line 306 of file BLI_array.hh.

References data_.

Referenced by blender::Array< T, InlineBufferCapacity, Allocator >::rend().

◆ clear_without_destruct()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
void blender::Array< T, InlineBufferCapacity, Allocator >::clear_without_destruct ( )
inline

Sets the size to zero. This should only be used when you have manually destructed all elements in the array beforehand. Use with care.

Definition at line 354 of file BLI_array.hh.

◆ data() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T* blender::Array< T, InlineBufferCapacity, Allocator >::data ( )
inline

Definition at line 301 of file BLI_array.hh.

References data_.

◆ data() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T* blender::Array< T, InlineBufferCapacity, Allocator >::data ( ) const
inline

Get a pointer to the beginning of the array.

Definition at line 297 of file BLI_array.hh.

References data_.

Referenced by BMD_mesh_intersection(), blender::string_search::damerau_levenshtein_distance(), and blender::tests::TEST().

◆ end() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T* blender::Array< T, InlineBufferCapacity, Allocator >::end ( )
inline

Definition at line 319 of file BLI_array.hh.

References data_.

◆ end() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T* blender::Array< T, InlineBufferCapacity, Allocator >::end ( ) const
inline

Definition at line 310 of file BLI_array.hh.

References data_.

Referenced by blender::Array< T, InlineBufferCapacity, Allocator >::rbegin().

◆ fill()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
void blender::Array< T, InlineBufferCapacity, Allocator >::fill ( const T value) const
inline

Copies the given value to every element in the array.

Definition at line 274 of file BLI_array.hh.

References data_, and blender::initialized_fill_n().

◆ index_range()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
IndexRange blender::Array< T, InlineBufferCapacity, Allocator >::index_range ( ) const
inline

Get an index range containing all valid indices for this array.

Definition at line 345 of file BLI_array.hh.

Referenced by blender::nodes::geo_node_point_distribute_exec(), and blender::nodes::get_geometry_element_ids_as_uints().

◆ inline_buffer_capacity()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
static int64_t blender::Array< T, InlineBufferCapacity, Allocator >::inline_buffer_capacity ( )
inlinestatic

Get the value of the InlineBufferCapacity template argument. This is the number of elements that can be stored without doing an allocation.

Definition at line 375 of file BLI_array.hh.

◆ is_empty()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
bool blender::Array< T, InlineBufferCapacity, Allocator >::is_empty ( ) const
inline

Returns true when the number of elements in the array is zero.

Definition at line 266 of file BLI_array.hh.

Referenced by blender::fn::GVectorArray::is_empty().

◆ last() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T& blender::Array< T, InlineBufferCapacity, Allocator >::last ( )
inline

Definition at line 288 of file BLI_array.hh.

References BLI_assert, and data_.

◆ last() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T& blender::Array< T, InlineBufferCapacity, Allocator >::last ( ) const
inline

Return a reference to the last element in the array. This invokes undefined behavior when the array is empty.

Definition at line 283 of file BLI_array.hh.

References BLI_assert, and data_.

◆ operator MutableSpan< T >()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::operator MutableSpan< T > ( )
inline

Definition at line 228 of file BLI_array.hh.

◆ operator MutableSpan< U >()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
template<typename U , typename std::enable_if_t< is_span_convertible_pointer_v< T, U >> * = nullptr>
blender::Array< T, InlineBufferCapacity, Allocator >::operator MutableSpan< U > ( )
inline

Definition at line 240 of file BLI_array.hh.

References data_.

◆ operator Span< T >()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
blender::Array< T, InlineBufferCapacity, Allocator >::operator Span< T > ( ) const
inline

Definition at line 223 of file BLI_array.hh.

◆ operator Span< U >()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
template<typename U , typename std::enable_if_t< is_span_convertible_pointer_v< T, U >> * = nullptr>
blender::Array< T, InlineBufferCapacity, Allocator >::operator Span< U > ( ) const
inline

Definition at line 234 of file BLI_array.hh.

References data_.

◆ operator=() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
Array& blender::Array< T, InlineBufferCapacity, Allocator >::operator= ( Array< T, InlineBufferCapacity, Allocator > &&  other)
inlinenoexcept

Definition at line 204 of file BLI_array.hh.

References blender::move_assign_container().

◆ operator=() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
Array& blender::Array< T, InlineBufferCapacity, Allocator >::operator= ( const Array< T, InlineBufferCapacity, Allocator > &  other)
inline

Definition at line 199 of file BLI_array.hh.

References blender::copy_assign_container().

◆ operator[]() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
T& blender::Array< T, InlineBufferCapacity, Allocator >::operator[] ( int64_t  index)
inline

Definition at line 209 of file BLI_array.hh.

References BLI_assert, and data_.

◆ operator[]() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
const T& blender::Array< T, InlineBufferCapacity, Allocator >::operator[] ( int64_t  index) const
inline

Definition at line 216 of file BLI_array.hh.

References BLI_assert, and data_.

◆ rbegin() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
std::reverse_iterator<T *> blender::Array< T, InlineBufferCapacity, Allocator >::rbegin ( )
inline

◆ rbegin() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
std::reverse_iterator<const T *> blender::Array< T, InlineBufferCapacity, Allocator >::rbegin ( ) const
inline

◆ reinitialize()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
void blender::Array< T, InlineBufferCapacity, Allocator >::reinitialize ( const int64_t  new_size)
inline

Destruct values and create a new array of the given size. The values in the new array are default constructed.

Definition at line 384 of file BLI_array.hh.

References BLI_assert, data_, blender::default_construct_n(), blender::destruct_n(), and T.

◆ rend() [1/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
std::reverse_iterator<T *> blender::Array< T, InlineBufferCapacity, Allocator >::rend ( )
inline

◆ rend() [2/2]

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
std::reverse_iterator<const T *> blender::Array< T, InlineBufferCapacity, Allocator >::rend ( ) const
inline

◆ size()

template<typename T , int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
int64_t blender::Array< T, InlineBufferCapacity, Allocator >::size ( ) const
inline

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