Blender V4.5
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
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 ()

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 152 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 160 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 162 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 180 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 376 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 380 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 319 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 368 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 305 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 323 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 275 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 270 of file BLI_array.hh.

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

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

Referenced by BKE_editmesh_looptris_calc_with_partial_ex(), BKE_sculptsession_free_vwpaint_data(), BKE_subdiv_ccg_start_face_grid_index_ensure(), 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::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 291 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 285 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 215 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 227 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 210 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 221 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 191 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 186 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 196 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 203 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 328 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 337 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 332 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 341 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 359 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 354 of file BLI_array.hh.


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