Blender V4.3
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 11 of file BLI_index_ranges_builder_fwd.hh.

Constructor & Destructor Documentation

◆ IndexRangesBuilder()

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

Definition at line 33 of file BLI_index_ranges_builder.hh.

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 43 of file BLI_index_ranges_builder.hh.

References blender::IndexRangesBuilder< T >::add_range().

◆ 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 52 of file BLI_index_ranges_builder.hh.

References BLI_assert, blender::IndexRangesBuilder< T >::capacity(), and blender::IndexRangesBuilder< T >::size().

Referenced by blender::IndexRangesBuilder< T >::add(), and blender::bits::bits_to_index_ranges().

◆ buffer_size_for_ranges_num()

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

Definition at line 105 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 81 of file BLI_index_ranges_builder.hh.

Referenced by blender::IndexRangesBuilder< T >::add_range().

◆ index_range()

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

◆ is_empty()

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

True if there are no ranges yet.

Definition at line 87 of file BLI_index_ranges_builder.hh.

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

◆ operator[]()

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

Get the i-th collected #IndexRange.

Definition at line 98 of file BLI_index_ranges_builder.hh.

References blender::IndexRange::from_begin_end().

◆ size()


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