Blender V5.0
blender::IndexRangesBuilder< T > Class Template Reference

#include <BLI_index_ranges_builder.hh>

Inherits blender::NonCopyable, and blender::NonMovable.

Public Member Functions

 IndexRangesBuilder (MutableSpan< T > data)
bool add (const T index)
bool add_range (const T start, const T end)
int64_t size () const
int64_t capacity () const
bool is_empty () const
IndexRange index_range () const
IndexRange operator[] (const int64_t i) const

Static Public Member Functions

static constexpr int64_t buffer_size_for_ranges_num (const int64_t ranges_num)

Detailed Description

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

A data structure that is designed to allow building many index ranges efficiently.

One first has to add individual indices or ranges in ascending order. Internally, consecutive indices and ranges are automatically joined.

Note
This data structure has a pre-defined capacity and can not automatically grow once that capacity is reached. Use IndexRangesBuilderBuffer to control the capacity.

Definition at line 29 of file BLI_index_ranges_builder.hh.

Constructor & Destructor Documentation

◆ IndexRangesBuilder()

template<typename T>
blender::IndexRangesBuilder< T >::IndexRangesBuilder ( MutableSpan< T > data)
inline

Definition at line 37 of file BLI_index_ranges_builder.hh.

References data.

Member Function Documentation

◆ add()

template<typename T>
bool blender::IndexRangesBuilder< T >::add ( const T index)
inline

Add a new index. It has to be larger than any previously added index.

Definition at line 47 of file BLI_index_ranges_builder.hh.

References add_range(), and T.

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

◆ add_range()

template<typename T>
bool blender::IndexRangesBuilder< T >::add_range ( const T start,
const T end )
inline

Add a range of indices. It has to start after any previously added index. By design, this is branchless and requires O(1) time.

Definition at line 56 of file BLI_index_ranges_builder.hh.

References BLI_assert, capacity(), size(), and T.

Referenced by add(), blender::bits::bits_to_index_ranges(), blender::geometry::face_tris_mask(), and blender::tests::TEST().

◆ buffer_size_for_ranges_num()

template<typename T>
constexpr int64_t blender::IndexRangesBuilder< T >::buffer_size_for_ranges_num ( const int64_t ranges_num)
inlinestaticconstexpr

Definition at line 109 of file BLI_index_ranges_builder.hh.

◆ capacity()

template<typename T>
int64_t blender::IndexRangesBuilder< T >::capacity ( ) const
inline

How many ranges this container can hold at most.

Definition at line 85 of file BLI_index_ranges_builder.hh.

Referenced by add_range().

◆ index_range()

template<typename T>
IndexRange blender::IndexRangesBuilder< T >::index_range ( ) const
inline

Definition at line 96 of file BLI_index_ranges_builder.hh.

References size().

Referenced by blender::index_mask::segments_from_batch_predicate().

◆ is_empty()

template<typename T>
bool blender::IndexRangesBuilder< T >::is_empty ( ) const
inline

True if there are no ranges yet.

Definition at line 91 of file BLI_index_ranges_builder.hh.

Referenced by blender::index_mask::segments_from_batch_predicate(), and blender::tests::TEST().

◆ operator[]()

template<typename T>
IndexRange blender::IndexRangesBuilder< T >::operator[] ( const int64_t i) const
inline

Get the i-th collected IndexRange.

Definition at line 102 of file BLI_index_ranges_builder.hh.

References blender::IndexRange::from_begin_end(), i, and T.

◆ size()


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