Blender  V3.3
Classes | Public Member Functions | Friends | List of all members
blender::IndexRange Class Reference

#include <BLI_index_range.hh>

Classes

class  Iterator
 

Public Member Functions

constexpr IndexRange ()=default
 
constexpr IndexRange (int64_t size)
 
constexpr IndexRange (int64_t start, int64_t size)
 
constexpr Iterator begin () const
 
constexpr Iterator end () const
 
constexpr int64_t operator[] (int64_t index) const
 
constexpr int64_t size () const
 
constexpr bool is_empty () const
 
constexpr IndexRange after (int64_t n) const
 
constexpr IndexRange before (int64_t n) const
 
constexpr int64_t first () const
 
constexpr int64_t last (const int64_t n=0) const
 
constexpr int64_t one_before_start () const
 
constexpr int64_t one_after_last () const
 
constexpr int64_t start () const
 
constexpr bool contains (int64_t value) const
 
constexpr IndexRange slice (int64_t start, int64_t size) const
 
constexpr IndexRange slice (IndexRange range) const
 
constexpr IndexRange drop_front (int64_t n) const
 
constexpr IndexRange drop_back (int64_t n) const
 
constexpr IndexRange take_front (int64_t n) const
 
constexpr IndexRange take_back (int64_t n) const
 
constexpr IndexRange shift (int64_t n) const
 
Span< int64_tas_span () const
 

Friends

constexpr friend bool operator== (IndexRange a, IndexRange b)
 
std::ostream & operator<< (std::ostream &stream, IndexRange range)
 

Detailed Description

Definition at line 52 of file BLI_index_range.hh.

Constructor & Destructor Documentation

◆ IndexRange() [1/3]

constexpr blender::IndexRange::IndexRange ( )
constexprdefault

◆ IndexRange() [2/3]

constexpr blender::IndexRange::IndexRange ( int64_t  size)
inlineexplicitconstexpr

Definition at line 60 of file BLI_index_range.hh.

References BLI_assert, and size().

◆ IndexRange() [3/3]

constexpr blender::IndexRange::IndexRange ( int64_t  start,
int64_t  size 
)
inlineconstexpr

Definition at line 65 of file BLI_index_range.hh.

References BLI_assert, size(), and start().

Member Function Documentation

◆ after()

constexpr IndexRange blender::IndexRange::after ( int64_t  n) const
inlineconstexpr

◆ as_span()

Span< int64_t > blender::IndexRange::as_span ( ) const
inline

Get read-only access to a memory buffer that contains the range as actual numbers.

This is defined here, because in BLI_index_range.hh Span is not yet defined.

Definition at line 726 of file BLI_span.hh.

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

◆ before()

constexpr IndexRange blender::IndexRange::before ( int64_t  n) const
inlineconstexpr

Create a new range that ends at the start of the current one.

Definition at line 172 of file BLI_index_range.hh.

References BLI_assert, and IndexRange().

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

◆ begin()

constexpr Iterator blender::IndexRange::begin ( ) const
inlineconstexpr

Definition at line 116 of file BLI_index_range.hh.

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

◆ contains()

constexpr bool blender::IndexRange::contains ( int64_t  value) const
inlineconstexpr

Returns true when the range contains a certain number, otherwise false.

Definition at line 229 of file BLI_index_range.hh.

Referenced by blender::ui::BuildOnlyVisibleButtonsHelper::is_item_visible(), blender::bke::curves::bezier::segment_is_vector(), and blender::tests::TEST().

◆ drop_back()

constexpr IndexRange blender::IndexRange::drop_back ( int64_t  n) const
inlineconstexpr

◆ drop_front()

constexpr IndexRange blender::IndexRange::drop_front ( int64_t  n) const
inlineconstexpr

◆ end()

constexpr Iterator blender::IndexRange::end ( ) const
inlineconstexpr

Definition at line 121 of file BLI_index_range.hh.

◆ first()

constexpr int64_t blender::IndexRange::first ( ) const
inlineconstexpr

◆ is_empty()

constexpr bool blender::IndexRange::is_empty ( ) const
inlineconstexpr

Returns true if the size is zero.

Definition at line 155 of file BLI_index_range.hh.

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

◆ last()

constexpr int64_t blender::IndexRange::last ( const int64_t  n = 0) const
inlineconstexpr

◆ one_after_last()

constexpr int64_t blender::IndexRange::one_after_last ( ) const
inlineconstexpr

◆ one_before_start()

constexpr int64_t blender::IndexRange::one_before_start ( ) const
inlineconstexpr

Get the element one before the beginning. The returned value is undefined when the range is empty, and the range must start after zero already.

Definition at line 204 of file BLI_index_range.hh.

References BLI_assert.

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

◆ operator[]()

constexpr int64_t blender::IndexRange::operator[] ( int64_t  index) const
inlineconstexpr

Access an element in the range.

Definition at line 129 of file BLI_index_range.hh.

References BLI_assert, and size().

◆ shift()

constexpr IndexRange blender::IndexRange::shift ( int64_t  n) const
inlineconstexpr

Move the range forward or backward within the larger array. The amount may be negative, but its absolute value cannot be greater than the existing start of the range.

Definition at line 298 of file BLI_index_range.hh.

References IndexRange().

Referenced by blender::geometry::subdivide_bezier_segment().

◆ size()

constexpr int64_t blender::IndexRange::size ( ) const
inlineconstexpr

Get the amount of numbers in the range.

Definition at line 147 of file BLI_index_range.hh.

Referenced by blender::nodes::node_geo_instance_on_points_cc::add_instances_from_component(), blender::bke::calculate_evaluated_offsets(), blender::bke::calculate_result_offsets(), blender::IndexMask::contained_in(), blender::bke::copy_between_buffers(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_faces(), blender::nodes::node_geo_extrude_mesh_cc::copy_with_mixing(), blender::bke::copy_with_removed_curves(), curve_create_curves_lines(), blender::geometry::curve_dst_offsets(), curve_eval_render_wire_verts_edges_len_get(), blender::bke::curve_to_mesh_sweep(), curves_batch_cache_fill_strands_data(), curves_to_curve_eval(), blender::nodes::node_geo_curve_fill_cc::do_cdt(), DRW_shgroup_curves_create_sub(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_faces(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_instances(), blender::bke::CurvesGeometry::evaluated_normals(), blender::fn::materialize_detail::execute_materialized_impl(), blender::IndexMask::extract_ranges_invert(), 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::ed::sculpt_paint::find_curves_brush_position(), first(), IndexRange(), blender::geometry::interpolate_position_with_interpolation(), blender::bke::CurvesGeometry::interpolate_to_evaluated(), blender::IndexMask::invert(), last(), blender::GVArrayImpl_For_SlicedGVArray::materialize_compressed_to_uninitialized(), operator[](), blender::threading::parallel_for(), blender::threading::parallel_reduce(), blender::GSpan::slice(), blender::GMutableSpan::slice(), blender::Span< T >::slice(), blender::MutableSpan< T >::slice(), blender::GVArray::slice(), slice(), blender::geometry::subdivide_bezier_segment(), blender::tests::TEST(), and blender::ed::curves::convert_to_particle_system::try_convert_single_object().

◆ slice() [1/2]

constexpr IndexRange blender::IndexRange::slice ( IndexRange  range) const
inlineconstexpr

Definition at line 245 of file BLI_index_range.hh.

References size(), slice(), and start().

◆ slice() [2/2]

constexpr IndexRange blender::IndexRange::slice ( int64_t  start,
int64_t  size 
) const
inlineconstexpr

Returns a new range, that contains a sub-interval of the current one.

Definition at line 237 of file BLI_index_range.hh.

References BLI_assert, IndexRange(), size(), and start().

Referenced by slice(), blender::tests::TEST(), and blender::geometry::weld_poly_loop_ctx_alloc().

◆ start()

constexpr int64_t blender::IndexRange::start ( ) const
inlineconstexpr

◆ take_back()

constexpr IndexRange blender::IndexRange::take_back ( int64_t  n) const
inlineconstexpr

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

Definition at line 287 of file BLI_index_range.hh.

References BLI_assert, and IndexRange().

◆ take_front()

constexpr IndexRange blender::IndexRange::take_front ( int64_t  n) const
inlineconstexpr

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

Definition at line 276 of file BLI_index_range.hh.

References BLI_assert, and IndexRange().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
IndexRange  range 
)
friend

Definition at line 308 of file BLI_index_range.hh.

◆ operator==

constexpr friend bool operator== ( IndexRange  a,
IndexRange  b 
)
friend

Two ranges compare equal when they contain the same numbers.

Definition at line 139 of file BLI_index_range.hh.


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