Blender V5.0
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, BLI_ENABLE_IF((std::is_convertible_v< U, T >))>
 Array (Span< U > values, Allocator allocator={})
template<typename U, BLI_ENABLE_IF((std::is_convertible_v< U, T >))>
 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, BLI_ENABLE_IF((is_span_convertible_pointer_v< T, U >))>
 operator Span< U > () const
template<typename U, BLI_ENABLE_IF((is_span_convertible_pointer_v< T, U >))>
 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 Tfirst () const
Tfirst ()
const Tlast (const int64_t n=0) const
Tlast (const int64_t n=0)
const Tdata () const
Tdata ()
const Tbegin () const
Tbegin ()
const Tend () const
Tend ()
std::reverse_iterator< T * > rbegin ()
std::reverse_iterator< const T * > rbegin () const
std::reverse_iterator< T * > rend ()
std::reverse_iterator< const T * > rend () const
IndexRange index_range () const
uint64_t hash () const
void clear_without_destruct ()
Allocator & allocator ()
const Allocator & allocator () const
void reinitialize (const int64_t new_size)

Static Public Member Functions

static uint64_t hash_as (const Span< T > values)
static int64_t inline_buffer_capacity ()

Friends

bool operator== (const Array &a, const Array &b)
bool operator!= (const Array &a, const Array &b)

Detailed Description

template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
class Array< T, InlineBufferCapacity, Allocator >
Template Parameters
TThe type of the values stored in the array.
InlineBufferCapacityThe number of values that can be stored in the array, without doing a heap allocation.
AllocatorThe allocator used by this array. Should rarely be changed, except when you don't want that MEM_* functions are used internally.

Definition at line 50 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 58 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 54 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 56 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 57 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 53 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 55 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 59 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 52 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 78 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 84 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, BLI_ENABLE_IF((std::is_convertible_v< U, T >))>
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 90 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, BLI_ENABLE_IF((std::is_convertible_v< U, T >))>
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 102 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 107 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 120 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 131 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 159 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 167 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 169 of file BLI_array.hh.

◆ ~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 191 of file BLI_array.hh.

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 397 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 401 of file BLI_array.hh.

◆ as_mutable_span()

◆ as_span()

◆ 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 330 of file BLI_array.hh.

◆ 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

◆ 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 389 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 316 of file BLI_array.hh.

◆ data() [2/2]

◆ 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 334 of file BLI_array.hh.

◆ 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

◆ 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

◆ first() [1/2]

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

Definition at line 286 of file BLI_array.hh.

◆ first() [2/2]

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

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

Definition at line 281 of file BLI_array.hh.

Referenced by blender::draw::discard_buffers(), M_Geometry_delaunay_2d_cdt(), blender::meshintersect::operator<<(), and blender::geometry::preprocess_meshes().

◆ hash()

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

Definition at line 365 of file BLI_array.hh.

◆ hash_as()

template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
uint64_t blender::Array< T, InlineBufferCapacity, Allocator >::hash_as ( const Span< T > values)
inlinestatic

Definition at line 370 of file BLI_array.hh.

◆ index_range()

◆ inline_buffer_capacity()

template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
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 410 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 264 of file BLI_array.hh.

Referenced by BKE_editmesh_looptris_calc_with_partial_ex(), BKE_editmesh_orco_tangents_calc(), BKE_editmesh_uv_tangents_calc(), BKE_sculptsession_free_vwpaint_data(), blendthumb_create_png_data_from_thumb(), blender::ed::sculpt_paint::auto_mask::calc_face_factors(), blender::ed::sculpt_paint::auto_mask::calc_grids_factors(), blender::ed::sculpt_paint::auto_mask::calc_vert_factors(), blender::ed::sculpt_paint::auto_mask::calc_vert_factors(), blender::draw::discard_buffers(), blender::ed::sculpt_paint::brushes::do_layer_brush(), blender::ed::sculpt_paint::mask::duplicate_mask(), blender::draw::extract_tris_subdiv(), blender::ed::sculpt_paint::fill_factor_from_hide_and_mask(), blender::ed::sculpt_paint::mask::fill_mask_grids(), blender::ed::sculpt_paint::mask::gather_mask_grids(), blender::ed::sculpt_paint::boundary::init_falloff_grids(), blender::ed::sculpt_paint::vwpaint::init_session_data(), blender::geometry::lookup_tris_in_cell(), blender::bke::mesh_apply_spatial_organization(), blender::draw::mesh_render_data_loose_geom_ensure(), blender::draw::overlay::Sculpts::mesh_sync(), multires_reshape_assign_final_coords_from_ccg(), SCULPT_fake_neighbors_ensure(), blender::ed::sculpt_paint::sculpt_geometry_preview_lines_draw(), blender::ed::sculpt_paint::undo::store_mask_grids(), blender::bke::subdiv::subdiv_to_mesh(), blender::bke::pbvh::update_mask_grids(), blender::ed::sculpt_paint::islands::vert_id_get(), blender::ed::sculpt_paint::expand::vert_to_face_falloff(), and wpaint_stroke_test_start().

◆ 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 ( const int64_t n = 0)
inline

Definition at line 302 of file BLI_array.hh.

◆ 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 int64_t n = 0) const
inline

Return a reference to the nth last element. This invokes undefined behavior when the array is too short.

Definition at line 296 of file BLI_array.hh.

Referenced by blender::bke::curve_to_mesh_sweep().

◆ 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 226 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, BLI_ENABLE_IF((is_span_convertible_pointer_v< T, U >))>
blender::Array< T, InlineBufferCapacity, Allocator >::operator MutableSpan< U > ( )
inline

Definition at line 238 of file BLI_array.hh.

◆ 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 221 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, BLI_ENABLE_IF((is_span_convertible_pointer_v< T, U >))>
blender::Array< T, InlineBufferCapacity, Allocator >::operator Span< U > ( ) const
inline

Definition at line 232 of file BLI_array.hh.

◆ 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 202 of file BLI_array.hh.

◆ 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 197 of file BLI_array.hh.

◆ 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 207 of file BLI_array.hh.

◆ 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 214 of file BLI_array.hh.

◆ 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

Definition at line 339 of file BLI_array.hh.

◆ 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

Definition at line 348 of file BLI_array.hh.

◆ 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

◆ 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

Definition at line 343 of file BLI_array.hh.

◆ 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

Definition at line 352 of file BLI_array.hh.

◆ size()

◆ operator!=

template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
bool operator!= ( const Array< T, InlineBufferCapacity, Allocator > & a,
const Array< T, InlineBufferCapacity, Allocator > & b )
friend

Definition at line 380 of file BLI_array.hh.

◆ operator==

template<typename T, int64_t InlineBufferCapacity = default_inline_buffer_capacity(sizeof(T)), typename Allocator = GuardedAllocator>
bool operator== ( const Array< T, InlineBufferCapacity, Allocator > & a,
const Array< T, InlineBufferCapacity, Allocator > & b )
friend

Definition at line 375 of file BLI_array.hh.


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