Blender V5.0
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 >

This class is a thin wrapper around an array of increasing indices that makes it easy to retrieve an index range at a specific index. Each index range is typically a representation of a contiguous chunk of a larger array.

Another common way to store many index ranges is to store the start and size of every range. Using OffsetIndices instead requires that chunks are ordered consecutively but halves the memory consumption. Another downside is that the underlying array has to be one element longer than the total number of ranges. The extra element necessary to encode the size of the last range without requiring a branch for each range access.

Definition at line 34 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 42 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 52 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 106 of file BLI_offset_indices.hh.

◆ index_range()

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

Definition at line 74 of file BLI_offset_indices.hh.

◆ is_empty()

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

Definition at line 69 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 88 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 79 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 64 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 100 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 55 of file BLI_offset_indices.hh.

Referenced by blender::bke::mesh::normals_calc_corners().


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