Blender  V2.93
Public Member Functions | List of all members
blender::IndexMask Class Reference

#include <BLI_index_mask.hh>

Public Member Functions

 IndexMask ()=default
 
 IndexMask (Span< int64_t > indices)
 
 IndexMask (IndexRange range)
 
 IndexMask (const std::initializer_list< int64_t > &indices)
 
 IndexMask (int64_t n)
 
 operator Span< int64_t > () const
 
const int64_tbegin () const
 
const int64_tend () const
 
int64_t operator[] (int64_t n) const
 
int64_t min_array_size () const
 
Span< int64_tindices () const
 
bool is_range () const
 
IndexRange as_range () const
 
template<typename CallbackT >
void foreach_index (const CallbackT &callback) const
 
IndexRange index_range () const
 
int64_t last () const
 
int64_t size () const
 

Detailed Description

Definition at line 45 of file BLI_index_mask.hh.

Constructor & Destructor Documentation

◆ IndexMask() [1/5]

blender::IndexMask::IndexMask ( )
default

◆ IndexMask() [2/5]

blender::IndexMask::IndexMask ( Span< int64_t indices)
inline

Create an IndexMask using the given integer array. This constructor asserts that the given integers are in ascending order and that there are no duplicates.

Definition at line 59 of file BLI_index_mask.hh.

References BLI_assert, indices(), and blender::Span< T >::size().

◆ IndexMask() [3/5]

blender::IndexMask::IndexMask ( IndexRange  range)
inline

Use this method when you know that no indices are skipped. It is more efficient than preparing an integer array all the time.

Definition at line 72 of file BLI_index_mask.hh.

◆ IndexMask() [4/5]

blender::IndexMask::IndexMask ( const std::initializer_list< int64_t > &  indices)
inline

Construct an IndexMask from a sorted list of indices. Note, the created IndexMask is only valid as long as the initializer_list is valid.

Don't do this: IndexMask mask = {3, 4, 5};

Do this: do_something_with_an_index_mask({3, 4, 5});

Definition at line 86 of file BLI_index_mask.hh.

◆ IndexMask() [5/5]

blender::IndexMask::IndexMask ( int64_t  n)
inlineexplicit

Creates an IndexMask that references the indices [0, n-1].

Definition at line 93 of file BLI_index_mask.hh.

Member Function Documentation

◆ as_range()

IndexRange blender::IndexMask::as_range ( ) const
inline

Returns the IndexRange referenced by this IndexMask. This method should only be called after the caller made sure that this IndexMask is actually a range.

Definition at line 152 of file BLI_index_mask.hh.

References BLI_assert, blender::Span< T >::first(), is_range(), and blender::Span< T >::size().

Referenced by foreach_index().

◆ begin()

const int64_t* blender::IndexMask::begin ( ) const
inline

Definition at line 102 of file BLI_index_mask.hh.

References blender::Span< T >::begin().

◆ end()

const int64_t* blender::IndexMask::end ( ) const
inline

Definition at line 107 of file BLI_index_mask.hh.

References blender::Span< T >::end().

◆ foreach_index()

template<typename CallbackT >
void blender::IndexMask::foreach_index ( const CallbackT &  callback) const
inline

Calls the given callback for every referenced index. The callback has to take one unsigned integer as parameter.

This method implements different code paths for the cases when the IndexMask represents a range or not.

Definition at line 165 of file BLI_index_mask.hh.

References as_range(), callback, and is_range().

◆ index_range()

IndexRange blender::IndexMask::index_range ( ) const
inline

Returns an IndexRange that can be used to index this IndexMask.

The range is [0, number of indices - 1].

This is not to be confused with the as_range method.

Definition at line 187 of file BLI_index_mask.hh.

References blender::Span< T >::index_range().

◆ indices()

Span<int64_t> blender::IndexMask::indices ( ) const
inline

Definition at line 135 of file BLI_index_mask.hh.

Referenced by IndexMask().

◆ is_range()

bool blender::IndexMask::is_range ( ) const
inline

Returns true if this IndexMask does not skip any indices. This check requires O(1) time.

Definition at line 143 of file BLI_index_mask.hh.

References blender::Span< T >::first(), blender::Span< T >::last(), and blender::Span< T >::size().

Referenced by as_range(), and foreach_index().

◆ last()

int64_t blender::IndexMask::last ( ) const
inline

Returns the largest index that is referenced by this IndexMask.

Definition at line 195 of file BLI_index_mask.hh.

References blender::Span< T >::last().

◆ min_array_size()

int64_t blender::IndexMask::min_array_size ( ) const
inline

Returns the minimum size an array has to have, if the integers in this IndexMask are going to be used as indices in that array.

Definition at line 125 of file BLI_index_mask.hh.

References blender::Span< T >::last(), and blender::Span< T >::size().

◆ operator Span< int64_t >()

blender::IndexMask::operator Span< int64_t > ( ) const
inline

Definition at line 97 of file BLI_index_mask.hh.

◆ operator[]()

int64_t blender::IndexMask::operator[] ( int64_t  n) const
inline

Returns the n-th index referenced by this IndexMask. The index_mask method returns an IndexRange containing all indices that can be used as parameter here.

Definition at line 116 of file BLI_index_mask.hh.

◆ size()

int64_t blender::IndexMask::size ( ) const
inline

Returns the number of indices referenced by this IndexMask.

Definition at line 203 of file BLI_index_mask.hh.

References blender::Span< T >::size().


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