Blender V5.0
MutableSpan< T > Class Template Reference

#include <BLI_span.hh>

Inherited by blender::MutableVArraySpan< T >.

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 size_type = int64_t

Public Member Functions

constexpr MutableSpan ()=default
constexpr MutableSpan (T *start, const int64_t size)
constexpr MutableSpan (std::vector< T > &vector)
template<std::size_t N>
constexpr MutableSpan (std::array< T, N > &array)
template<typename U, BLI_ENABLE_IF((is_span_convertible_pointer_v< U, T >))>
constexpr MutableSpan (MutableSpan< U > span)
constexpr operator Span< T > () const
template<typename U, BLI_ENABLE_IF((is_span_convertible_pointer_v< T, U >))>
constexpr operator Span< U > () const
constexpr int64_t size () const
constexpr int64_t size_in_bytes () const
constexpr bool is_empty () const
constexpr void fill (const T &value) const
template<typename IndexT>
constexpr void fill_indices (Span< IndexT > indices, const T &value) const
constexpr Tdata () const
constexpr Tbegin () const
constexpr Tend () const
constexpr std::reverse_iterator< T * > rbegin () const
constexpr std::reverse_iterator< T * > rend () const
constexpr Toperator[] (const int64_t index) const
constexpr MutableSpan slice (const int64_t start, const int64_t size) const
constexpr MutableSpan slice (IndexRange range) const
constexpr MutableSpan slice_safe (const int64_t start, const int64_t size) const
constexpr MutableSpan slice_safe (IndexRange range) const
constexpr MutableSpan drop_front (const int64_t n) const
constexpr MutableSpan drop_back (const int64_t n) const
constexpr MutableSpan take_front (const int64_t n) const
constexpr MutableSpan take_back (const int64_t n) const
constexpr void reverse () const
constexpr Span< Tas_span () const
constexpr IndexRange index_range () const
constexpr Tfirst () const
constexpr Tlast (const int64_t n=0) const
constexpr int64_t count (const T &value) const
constexpr bool contains (const T &value) const
constexpr bool contains_ptr (const T *ptr) const
constexpr void copy_from (Span< T > values) const
template<typename NewT>
constexpr MutableSpan< NewT > cast () const

Protected Attributes

Tdata_ = nullptr
int64_t size_ = 0

Detailed Description

template<typename T>
class MutableSpan< T >

Mostly the same as Span, except that one can change the array elements through a MutableSpan.

Definition at line 443 of file BLI_span.hh.

Member Typedef Documentation

◆ const_pointer

template<typename T>
using blender::MutableSpan< T >::const_pointer = const T *

Definition at line 447 of file BLI_span.hh.

◆ const_reference

template<typename T>
using blender::MutableSpan< T >::const_reference = const T &

Definition at line 449 of file BLI_span.hh.

◆ iterator

template<typename T>
using blender::MutableSpan< T >::iterator = T *

Definition at line 450 of file BLI_span.hh.

◆ pointer

template<typename T>
using blender::MutableSpan< T >::pointer = T *

Definition at line 446 of file BLI_span.hh.

◆ reference

template<typename T>
using blender::MutableSpan< T >::reference = T &

Definition at line 448 of file BLI_span.hh.

◆ size_type

template<typename T>
using blender::MutableSpan< T >::size_type = int64_t

Definition at line 451 of file BLI_span.hh.

◆ value_type

template<typename T>
using blender::MutableSpan< T >::value_type = T

Definition at line 445 of file BLI_span.hh.

Constructor & Destructor Documentation

◆ MutableSpan() [1/5]

template<typename T>
blender::MutableSpan< T >::MutableSpan ( )
constexprdefault

◆ MutableSpan() [2/5]

template<typename T>
blender::MutableSpan< T >::MutableSpan ( T * start,
const int64_t size )
inlineconstexpr

Definition at line 460 of file BLI_span.hh.

◆ MutableSpan() [3/5]

template<typename T>
blender::MutableSpan< T >::MutableSpan ( std::vector< T > & vector)
inlineconstexpr

Definition at line 462 of file BLI_span.hh.

◆ MutableSpan() [4/5]

template<typename T>
template<std::size_t N>
blender::MutableSpan< T >::MutableSpan ( std::array< T, N > & array)
inlineconstexpr

Definition at line 465 of file BLI_span.hh.

◆ MutableSpan() [5/5]

template<typename T>
template<typename U, BLI_ENABLE_IF((is_span_convertible_pointer_v< U, T >))>
blender::MutableSpan< T >::MutableSpan ( MutableSpan< U > span)
inlineconstexpr

Support implicit conversions like the one below: MutableSpan<T *> -> MutableSpan<const T *>

Definition at line 474 of file BLI_span.hh.

Member Function Documentation

◆ as_span()

template<typename T>
Span< T > blender::MutableSpan< T >::as_span ( ) const
inlineconstexpr

Returns an (immutable) Span that references the same array. This is usually not needed, due to implicit conversions. However, sometimes automatic type deduction needs some help.

Definition at line 661 of file BLI_span.hh.

◆ begin()

template<typename T>
T * blender::MutableSpan< T >::begin ( ) const
inlineconstexpr

Definition at line 544 of file BLI_span.hh.

◆ cast()

template<typename T>
template<typename NewT>
MutableSpan< NewT > blender::MutableSpan< T >::cast ( ) const
inlineconstexpr

Returns a new span to the same underlying memory buffer. No conversions are done. The caller is responsible for making sure that the type cast is valid.

Definition at line 749 of file BLI_span.hh.

◆ contains()

template<typename T>
bool blender::MutableSpan< T >::contains ( const T & value) const
inlineconstexpr

Does a linear search to see of the value is in the array. Returns true if it is, otherwise false.

Definition at line 715 of file BLI_span.hh.

◆ contains_ptr()

template<typename T>
bool blender::MutableSpan< T >::contains_ptr ( const T * ptr) const
inlineconstexpr

Does a constant time check to see if the pointer points to a value in the referenced array. Return true if it is, otherwise false.

Definition at line 729 of file BLI_span.hh.

◆ copy_from()

◆ count()

template<typename T>
int64_t blender::MutableSpan< T >::count ( const T & value) const
inlineconstexpr

Does a linear search to count how often the value is in the array. Returns the number of occurrences.

Definition at line 700 of file BLI_span.hh.

◆ data()

template<typename T>
T * blender::MutableSpan< T >::data ( ) const
inlineconstexpr

Returns a pointer to the beginning of the referenced array. This may be nullptr, when the size is zero.

Definition at line 539 of file BLI_span.hh.

Referenced by do_weight_paint_vertex_multi(), and do_weight_paint_vertex_single().

◆ drop_back()

template<typename T>
MutableSpan blender::MutableSpan< T >::drop_back ( const int64_t n) const
inlineconstexpr

Returns a new MutableSpan with n elements removed from the end. This invokes undefined behavior when n is negative.

Definition at line 618 of file BLI_span.hh.

Referenced by blender::geometry::create_curve_from_vert_indices(), and blender::ed::curves::resize_curves().

◆ drop_front()

template<typename T>
MutableSpan blender::MutableSpan< T >::drop_front ( const int64_t n) const
inlineconstexpr

Returns a new MutableSpan with n elements removed from the beginning. This invokes undefined behavior when n is negative.

Definition at line 607 of file BLI_span.hh.

Referenced by blender::ed::greasepencil::extrude_grease_pencil_curves().

◆ end()

template<typename T>
T * blender::MutableSpan< T >::end ( ) const
inlineconstexpr

Definition at line 548 of file BLI_span.hh.

◆ fill()

◆ fill_indices()

template<typename T>
template<typename IndexT>
void blender::MutableSpan< T >::fill_indices ( Span< IndexT > indices,
const T & value ) const
inlineconstexpr

Replace a subset of all elements with the given value. This invokes undefined behavior when one of the indices is out of bounds.

Definition at line 526 of file BLI_span.hh.

Referenced by blender::ed::sculpt_paint::cloth::apply_grab_brush().

◆ first()

◆ index_range()

template<typename T>
IndexRange blender::MutableSpan< T >::index_range ( ) const
inlineconstexpr

Utility to make it more convenient to iterate over all indices that can be used with this array.

Definition at line 670 of file BLI_span.hh.

Referenced by cloth_make_rest_mesh(), grease_pencil_do_layer_adjustments(), and versioning_grease_pencil_stroke_radii_scaling().

◆ is_empty()

template<typename T>
bool blender::MutableSpan< T >::is_empty ( ) const
inlineconstexpr

Returns true if the size is zero.

Definition at line 509 of file BLI_span.hh.

◆ last()

template<typename T>
T & blender::MutableSpan< T >::last ( const int64_t n = 0) const
inlineconstexpr

◆ operator Span< T >()

template<typename T>
blender::MutableSpan< T >::operator Span< T > ( ) const
inlineconstexpr

Definition at line 479 of file BLI_span.hh.

◆ operator Span< U >()

template<typename T>
template<typename U, BLI_ENABLE_IF((is_span_convertible_pointer_v< T, U >))>
blender::MutableSpan< T >::operator Span< U > ( ) const
inlineconstexpr

Definition at line 485 of file BLI_span.hh.

◆ operator[]()

template<typename T>
T & blender::MutableSpan< T >::operator[] ( const int64_t index) const
inlineconstexpr

Definition at line 562 of file BLI_span.hh.

◆ rbegin()

template<typename T>
std::reverse_iterator< T * > blender::MutableSpan< T >::rbegin ( ) const
inlineconstexpr

Definition at line 553 of file BLI_span.hh.

◆ rend()

template<typename T>
std::reverse_iterator< T * > blender::MutableSpan< T >::rend ( ) const
inlineconstexpr

Definition at line 557 of file BLI_span.hh.

◆ reverse()

template<typename T>
void blender::MutableSpan< T >::reverse ( ) const
inlineconstexpr

Reverse the data in the MutableSpan.

Definition at line 650 of file BLI_span.hh.

◆ size()

template<typename T>
int64_t blender::MutableSpan< T >::size ( ) const
inlineconstexpr

Returns the number of elements in the array.

Definition at line 493 of file BLI_span.hh.

◆ size_in_bytes()

template<typename T>
int64_t blender::MutableSpan< T >::size_in_bytes ( ) const
inlineconstexpr

Returns the number of bytes referenced by this Span.

Definition at line 501 of file BLI_span.hh.

◆ slice() [1/2]

◆ slice() [2/2]

template<typename T>
MutableSpan blender::MutableSpan< T >::slice ( IndexRange range) const
inlineconstexpr

Definition at line 581 of file BLI_span.hh.

◆ slice_safe() [1/2]

template<typename T>
MutableSpan blender::MutableSpan< T >::slice_safe ( const int64_t start,
const int64_t size ) const
inlineconstexpr

Returns a contiguous part of the array. This invokes undefined behavior when the start or size is negative. Clamps the size of the new span so it fits in the current one.

Definition at line 590 of file BLI_span.hh.

◆ slice_safe() [2/2]

template<typename T>
MutableSpan blender::MutableSpan< T >::slice_safe ( IndexRange range) const
inlineconstexpr

Definition at line 598 of file BLI_span.hh.

◆ take_back()

template<typename T>
MutableSpan blender::MutableSpan< T >::take_back ( const int64_t n) const
inlineconstexpr

Return a new MutableSpan that only contains the last n elements. This invokes undefined behavior when n is negative.

Definition at line 640 of file BLI_span.hh.

◆ take_front()

template<typename T>
MutableSpan blender::MutableSpan< T >::take_front ( const int64_t n) const
inlineconstexpr

Returns a new MutableSpan that only contains the first n elements. This invokes undefined behavior when n is negative.

Definition at line 629 of file BLI_span.hh.

Member Data Documentation

◆ data_

template<typename T>
T* blender::MutableSpan< T >::data_ = nullptr
protected

Definition at line 454 of file BLI_span.hh.

◆ size_

template<typename T>
int64_t blender::MutableSpan< T >::size_ = 0
protected

Definition at line 455 of file BLI_span.hh.


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