Blender  V3.3
Public Types | Public Member Functions | Protected Attributes | List of all members
blender::MutableSpan< T > Class Template Reference

#include <BLI_span.hh>

Inheritance diagram for blender::MutableSpan< T >:
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 bool is_empty () const
 
constexpr void fill (const T &value)
 
constexpr void fill_indices (Span< int64_t > indices, const T &value)
 
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 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 ()
 
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 void copy_from (Span< T > values)
 
template<typename NewT >
constexpr MutableSpan< NewT > cast () const
 

Protected Attributes

Tdata_ = nullptr
 
int64_t size_ = 0
 

Detailed Description

template<typename T>
class blender::MutableSpan< T >

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

Definition at line 457 of file BLI_span.hh.

Member Typedef Documentation

◆ const_pointer

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

Definition at line 461 of file BLI_span.hh.

◆ const_reference

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

Definition at line 463 of file BLI_span.hh.

◆ iterator

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

Definition at line 464 of file BLI_span.hh.

◆ pointer

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

Definition at line 460 of file BLI_span.hh.

◆ reference

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

Definition at line 462 of file BLI_span.hh.

◆ size_type

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

Definition at line 465 of file BLI_span.hh.

◆ value_type

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

Definition at line 459 of file BLI_span.hh.

Constructor & Destructor Documentation

◆ MutableSpan() [1/5]

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

◆ MutableSpan() [2/5]

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

Definition at line 474 of file BLI_span.hh.

◆ MutableSpan() [3/5]

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

Definition at line 478 of file BLI_span.hh.

◆ MutableSpan() [4/5]

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

Definition at line 483 of file BLI_span.hh.

◆ MutableSpan() [5/5]

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

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

Definition at line 492 of file BLI_span.hh.

Member Function Documentation

◆ as_span()

template<typename T >
constexpr 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 652 of file BLI_span.hh.

References blender::MutableSpan< T >::data_, and blender::MutableSpan< T >::size_.

◆ begin()

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

◆ cast()

template<typename T >
template<typename NewT >
constexpr 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 717 of file BLI_span.hh.

References BLI_assert, blender::MutableSpan< T >::data_, blender::MutableSpan< T >::size_, and T.

Referenced by blender::LinearAllocator< Allocator >::construct_elements_and_pointer_array().

◆ copy_from()

template<typename T >
constexpr void blender::MutableSpan< T >::copy_from ( Span< T values)
inlineconstexpr

◆ count()

template<typename T >
constexpr 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 691 of file BLI_span.hh.

References counter, element, and T.

◆ data()

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

◆ drop_back()

template<typename T >
constexpr 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 609 of file BLI_span.hh.

References BLI_assert, blender::MutableSpan< T >::data_, blender::MutableSpan< T >::MutableSpan(), and blender::MutableSpan< T >::size_.

Referenced by blender::bke::build_offsets(), and blender::nodes::node_geo_mesh_primitive_uv_sphere_cc::calculate_sphere_faces().

◆ drop_front()

template<typename T >
constexpr 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 598 of file BLI_span.hh.

References BLI_assert, blender::MutableSpan< T >::data_, blender::MutableSpan< T >::MutableSpan(), and blender::MutableSpan< T >::size_.

Referenced by blender::nodes::node_geo_mesh_primitive_uv_sphere_cc::calculate_sphere_faces(), and blender::tests::TEST().

◆ end()

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

◆ fill()

template<typename T >
constexpr void blender::MutableSpan< T >::fill ( const T value)
inlineconstexpr

Replace all elements in the referenced array with the given value.

Definition at line 527 of file BLI_span.hh.

References blender::MutableSpan< T >::data_, blender::initialized_fill_n(), and blender::MutableSpan< T >::size_.

Referenced by blender::bke::adapt_curve_domain_curve_to_point_impl(), blender::bke::adapt_curve_domain_point_to_curve_impl(), blender::bke::adapt_curve_domain_point_to_spline_impl(), blender::bke::adapt_mesh_domain_corner_to_edge_impl(), blender::bke::adapt_mesh_domain_corner_to_point_impl(), blender::bke::adapt_mesh_domain_edge_to_corner_impl(), blender::bke::adapt_mesh_domain_edge_to_point_impl(), blender::bke::adapt_mesh_domain_face_to_edge_impl(), blender::bke::adapt_mesh_domain_face_to_point_impl(), blender::geometry::add_curves_on_mesh(), blender::attribute_math::BooleanPropagationMixer::BooleanPropagationMixer(), blender::nodes::node_geo_dual_mesh_cc::calc_boundaries(), blender::nodes::node_geo_delete_geometry_cc::compute_selected_mesh_data_from_edge_selection(), blender::nodes::node_geo_delete_geometry_cc::compute_selected_mesh_data_from_poly_selection(), blender::nodes::node_geo_delete_geometry_cc::compute_selected_mesh_data_from_poly_selection_edge_face(), blender::bke::copy_main_point_data_to_mesh_edges(), blender::bke::copy_main_point_data_to_mesh_faces(), blender::bke::copy_main_point_data_to_mesh_verts(), blender::bke::copy_profile_point_data_to_mesh_edges(), blender::geometry::create_result_ids(), blender::geometry::execute_realize_curve_task(), blender::bke::get_mutable_attribute(), blender::io::obj::OBJMesh::get_poly_deform_group_index(), blender::geometry::interpolate_position_with_interpolation(), blender::string_search::match_word_initials(), blender::VArrayImpl_For_Single< T >::materialize_compressed(), blender::bke::point_attribute_materialize(), blender::ed::curves::select_all::select_all_exec(), blender::nodes::node_geo_curve_handle_type_selection_cc::select_by_handle_type(), blender::ed::sculpt_paint::select_end::select_end_exec(), blender::ed::sculpt_paint::select_random::select_random_exec(), blender::geometry::subdivide_bezier_segment(), blender::tests::TEST(), and blender::geometry::weld_poly_loop_ctx_setup().

◆ fill_indices()

template<typename T >
constexpr void blender::MutableSpan< T >::fill_indices ( Span< int64_t indices,
const T value 
)
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 536 of file BLI_span.hh.

References BLI_assert, blender::MutableSpan< T >::data_, indices, and blender::MutableSpan< T >::size_.

Referenced by blender::nodes::node_geo_curve_sample_cc::SampleCurveFunction::call(), blender::fn::tests::OptionalOutputsFunction::call(), blender::bke::VArrayImpl_For_VertexWeights::materialize(), and blender::tests::TEST().

◆ first()

template<typename T >
constexpr T& blender::MutableSpan< T >::first ( ) const
inlineconstexpr

◆ index_range()

template<typename T >
constexpr 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 661 of file BLI_span.hh.

References blender::MutableSpan< T >::size_.

Referenced by blender::bke::curves::accumulate_counts_to_offsets(), blender::bke::build_offsets(), NURBSpline::calculate_basis_cache(), calculate_normals_minimum(), calculate_normals_z_up(), compute_masked_vertices(), blender::nodes::node_geo_delete_geometry_cc::compute_selected_vertices_from_vertex_selection(), compute_vertex_mask__armature_mode(), compute_vertex_mask__vertex_group_mode(), blender::nodes::node_geo_dual_mesh_cc::copy_data_based_on_new_to_old_map(), blender::geometry::copy_generic_attributes_to_result(), blender::nodes::node_geo_extrude_mesh_cc::copy_with_indices(), blender::nodes::node_geo_extrude_mesh_cc::copy_with_mixing(), blender::geometry::create_nurbs_to_bezier_positions(), blender::geometry::create_result_ids(), blender::nodes::node_geo_curve_fill_cc::do_cdt(), blender::bke::curves::catmull_rom::evaluate_segment(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_edges(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_face_regions(), blender::attribute_math::SimpleMixer< T >::finalize(), blender::attribute_math::SimpleMixerWithAccumulationType< T, AccumulationT, ConvertToT >::finalize(), blender::geometry::initialize_straight_curve_positions(), blender::length_parameterize::interpolate(), blender::geometry::interpolate_from_neighbors(), blender::bke::curves::nurbs::interpolate_to_evaluated(), interpolate_to_evaluated_impl(), blender::bke::curves::nurbs::interpolate_to_evaluated_rational(), blender::ed::curves::select_all::invert_selection(), blender::bke::curves::bezier::linear_interpolation(), blender::geometry::linear_interpolation(), mesh_flush_select_from_verts(), blender::geometry::nurbs_to_bezier_assign(), blender::ed::curves::primitive_random_sphere(), blender::bke::CustomDataAttributes::reorder(), blender::bke::rotate_directions_around_axes(), blender::geometry::scale_input_assign(), blender::ed::sculpt_paint::select_random::select_random_exec(), blender::bke::VArrayImpl_For_SplinePosition::set_all(), blender::bke::VArrayImpl_For_BezierHandles::set_all(), blender::nodes::node_geo_dual_mesh_cc::sort_vertex_polys(), and blender::geometry::weld_edge_ctx_setup().

◆ is_empty()

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

◆ last()

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

◆ operator Span< T >()

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

Definition at line 497 of file BLI_span.hh.

◆ operator Span< U >()

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

◆ operator[]()

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

◆ rbegin()

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

Definition at line 562 of file BLI_span.hh.

References blender::MutableSpan< T >::end().

Referenced by blender::tests::TEST().

◆ rend()

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

Definition at line 566 of file BLI_span.hh.

References blender::MutableSpan< T >::begin().

Referenced by blender::tests::TEST().

◆ reverse()

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

Reverse the data in the MutableSpan.

Definition at line 641 of file BLI_span.hh.

References blender::MutableSpan< T >::data_, blender::MutableSpan< T >::size_, and swap().

Referenced by blender::tests::TEST().

◆ size()

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

Returns the number of elements in the array.

Definition at line 511 of file BLI_span.hh.

References blender::MutableSpan< T >::size_.

Referenced by blender::length_parameterize::accumulate_lengths(), blender::bke::adapt_curve_domain_point_to_spline_impl(), blender::bke::adapt_mesh_domain_corner_to_edge_impl(), blender::bke::adapt_mesh_domain_corner_to_point_impl(), blender::bke::adapt_mesh_domain_edge_to_corner_impl(), blender::bke::adapt_mesh_domain_edge_to_point_impl(), blender::bke::adapt_mesh_domain_face_to_corner_impl(), blender::bke::adapt_mesh_domain_face_to_edge_impl(), blender::bke::adapt_mesh_domain_face_to_point_impl(), add_interp_verts_copy_edges_to_new_mesh(), blender::nodes::node_geo_dual_mesh_cc::calc_boundaries(), blender::bke::curves::bezier::calculate_evaluated_offsets(), blender::bke::curves::bezier::calculate_evaluated_positions(), blender::bke::curves::nurbs::calculate_knots(), calculate_normals_minimum(), calculate_normals_z_up(), compute_masked_vertices(), blender::nodes::node_geo_delete_geometry_cc::compute_selected_edges_from_vertex_selection(), blender::nodes::node_geo_delete_geometry_cc::compute_selected_mesh_data_from_poly_selection(), blender::nodes::node_geo_delete_geometry_cc::compute_selected_mesh_data_from_poly_selection_edge_face(), blender::nodes::node_geo_delete_geometry_cc::compute_selected_vertices_from_vertex_selection(), computed_masked_edges(), computed_masked_edges_smooth(), blender::io::obj::copy_property_from_node(), blender::nodes::node_geo_extrude_mesh_cc::copy_with_indices(), blender::nodes::node_geo_extrude_mesh_cc::copy_with_mask(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_faces(), blender::bke::curves::catmull_rom::evaluate_segment(), blender::fn::materialize_detail::execute_materialized(), blender::RandomNumberGenerator::get_bytes(), blender::nodes::node_geo_transfer_attribute_cc::get_closest_in_bvhtree(), blender::nodes::node_geo_transfer_attribute_cc::get_closest_pointcloud_points(), blender::gpu::GLQueryPool::get_occlusion_result(), blender::io::obj::OBJMesh::get_poly_deform_group_index(), blender::bke::VArrayImpl_For_SplinePosition::get_position_spans(), blender::geometry::initialize_straight_curve_positions(), blender::bke::curves::catmull_rom::interpolate_to_evaluated(), blender::bke::curves::bezier::interpolate_to_evaluated(), interpolate_to_evaluated_impl(), blender::bke::curves::bezier::linear_interpolation(), blender::geometry::linear_interpolation(), blender::VArrayImpl< T >::materialize_compressed(), blender::VArrayImpl_For_Single< T >::materialize_compressed(), blender::VArrayImpl< T >::materialize_compressed_to_uninitialized(), blender::VArrayImpl_For_Single< T >::materialize_compressed_to_uninitialized(), blender::MutableSpan< T >::operator[](), blender::bke::calc_edges::reserve_hash_maps(), blender::length_parameterize::sample_at_lengths(), blender::geometry::ReverseUVSampler::sample_many(), blender::length_parameterize::sample_uniform(), blender::nodes::node_geo_material_selection_cc::select_mesh_by_material(), blender::bke::calc_edges::serialize_and_initialize_deduplicated_edges(), blender::RandomNumberGenerator::shuffle(), blender::MutableSpan< T >::slice(), blender::gpu::sort_input_list(), blender::nodes::node_geo_dual_mesh_cc::sort_vertex_polys(), blender::tests::TEST(), blender::nodes::node_geo_duplicate_elements_cc::threaded_id_offset_copy(), blender::nodes::node_geo_duplicate_elements_cc::threaded_slice_fill(), and blender::geometry::weld_edge_groups_setup().

◆ slice() [1/2]

template<typename T >
constexpr MutableSpan blender::MutableSpan< T >::slice ( 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.

Definition at line 581 of file BLI_span.hh.

References BLI_assert, blender::MutableSpan< T >::data_, min, blender::MutableSpan< T >::MutableSpan(), blender::MutableSpan< T >::size(), and blender::MutableSpan< T >::size_.

Referenced by blender::bke::adapt_curve_domain_curve_to_point_impl(), NURBSpline::calculate_basis_cache(), blender::bke::curves::nurbs::calculate_basis_cache(), blender::bke::CurvesGeometry::calculate_bezier_auto_handles(), blender::bke::calculate_evaluated_offsets(), blender::bke::copy_main_point_data_to_mesh_edges(), blender::bke::copy_main_point_data_to_mesh_faces(), blender::bke::copy_main_point_data_to_mesh_verts(), blender::bke::copy_profile_point_data_to_mesh_edges(), curves_batch_cache_fill_segments_proc_pos(), blender::bke::CurvesGeometry::ensure_evaluated_lengths(), blender::bke::CurvesGeometry::evaluated_normals(), blender::bke::CurvesGeometry::evaluated_positions(), blender::geometry::execute_realize_curve_task(), blender::geometry::execute_realize_pointcloud_task(), blender::nodes::node_geo_extrude_mesh_cc::extrude_individual_mesh_faces(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_edges(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_face_regions(), blender::bke::fill_mesh_topology(), blender::geometry::interpolate_position_with_interpolation(), blender::geometry::interpolate_position_without_interpolation(), blender::bke::curves::catmull_rom::interpolate_to_evaluated(), blender::bke::mark_bezier_vector_edges_sharp(), blender::bke::point_attribute_materialize(), blender::nodes::node_geo_curve_handle_type_selection_cc::select_by_handle_type(), blender::ed::sculpt_paint::select_random::select_random_exec(), blender::MutableSpan< T >::slice(), blender::geometry::subdivide_bezier_segment(), and blender::tests::TEST().

◆ slice() [2/2]

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

◆ take_back()

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

◆ take_front()

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

Member Data Documentation

◆ data_

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

◆ size_

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

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