Blender V4.3
blender::OffsetIndices< T > Class Template Reference

#include <BLI_offset_indices.hh>

Public Member Functions

 OffsetIndices ()=default
 OffsetIndices (const Span< T > offsets)
 OffsetIndices (const Span< T > offsets, NoSortCheck)
T total_size () const
int64_t size () const
bool is_empty () const
IndexRange index_range () const
IndexRange operator[] (const int64_t index) const
IndexRange operator[] (const IndexRange indices) const
OffsetIndices slice (const IndexRange range) const
Span< Tdata () const

Detailed Description

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

References an array of ascending indices. A pair of consecutive indices encode an index range. Another common way to store the same kind of data is to store the start and size of every range separately. Using offsets instead halves the memory consumption. The downside is that the array has to be one element longer than the total number of ranges. The extra element is necessary to be able to get the last index range without requiring an extra branch for the case.

This class is a thin wrapper around such an array that makes it easy to retrieve the index range at a specific index.

Definition at line 29 of file BLI_offset_indices.hh.

Constructor & Destructor Documentation

◆ OffsetIndices() [1/3]

template<typename T>
blender::offset_indices::OffsetIndices< T >::OffsetIndices ( )
default

◆ OffsetIndices() [2/3]

template<typename T>
blender::offset_indices::OffsetIndices< T >::OffsetIndices ( const Span< T > offsets)
inline

Definition at line 37 of file BLI_offset_indices.hh.

◆ OffsetIndices() [3/3]

template<typename T>
blender::offset_indices::OffsetIndices< T >::OffsetIndices ( const Span< T > offsets,
NoSortCheck  )
inline

Same as above, but skips the debug check that indices are sorted, because that can have a high performance impact making debug builds unusable for files that would be fine otherwise. This can be used when it is known that the indices are sorted already.

Definition at line 47 of file BLI_offset_indices.hh.

Member Function Documentation

◆ data()

template<typename T>
Span< T > blender::offset_indices::OffsetIndices< T >::data ( ) const
inline

Definition at line 101 of file BLI_offset_indices.hh.

◆ index_range()

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

Definition at line 69 of file BLI_offset_indices.hh.

◆ is_empty()

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

Definition at line 64 of file BLI_offset_indices.hh.

◆ operator[]() [1/2]

template<typename T>
IndexRange blender::offset_indices::OffsetIndices< T >::operator[] ( const IndexRange indices) const
inline

Definition at line 83 of file BLI_offset_indices.hh.

◆ operator[]() [2/2]

template<typename T>
IndexRange blender::offset_indices::OffsetIndices< T >::operator[] ( const int64_t index) const
inline

Definition at line 74 of file BLI_offset_indices.hh.

◆ size()

template<typename T>
int64_t blender::offset_indices::OffsetIndices< T >::size ( ) const
inline

Return the number of ranges encoded by the offsets, not including the last value used internally.

Definition at line 59 of file BLI_offset_indices.hh.

◆ slice()

template<typename T>
OffsetIndices blender::offset_indices::OffsetIndices< T >::slice ( const IndexRange range) const
inline

Return a subset of the offsets describing the specified range of source elements. This is a slice into the source ranges rather than the indexed elements described by the offset values.

Definition at line 95 of file BLI_offset_indices.hh.

◆ total_size()

template<typename T>
T blender::offset_indices::OffsetIndices< T >::total_size ( ) const
inline

Return the total number of elements in the referenced arrays.

Definition at line 50 of file BLI_offset_indices.hh.


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