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

#include <BLI_index_range.hh>

Classes

class  Iterator
 

Public Member Functions

constexpr IndexRange ()=default
 
constexpr IndexRange (int64_t size)
 
constexpr IndexRange (int64_t start, int64_t size)
 
constexpr Iterator begin () const
 
constexpr Iterator end () const
 
constexpr int64_t operator[] (int64_t index) const
 
constexpr int64_t size () const
 
constexpr IndexRange after (int64_t n) const
 
constexpr IndexRange before (int64_t n) const
 
constexpr int64_t first () const
 
constexpr int64_t last () const
 
constexpr int64_t one_after_last () const
 
constexpr int64_t start () const
 
constexpr bool contains (int64_t value) const
 
constexpr IndexRange slice (int64_t start, int64_t size) const
 
constexpr IndexRange slice (IndexRange range) const
 
Span< int64_tas_span () const
 

Friends

constexpr friend bool operator== (IndexRange a, IndexRange b)
 
std::ostream & operator<< (std::ostream &stream, IndexRange range)
 

Detailed Description

Definition at line 65 of file BLI_index_range.hh.

Constructor & Destructor Documentation

◆ IndexRange() [1/3]

constexpr blender::IndexRange::IndexRange ( )
constexprdefault

Referenced by after(), before(), and slice().

◆ IndexRange() [2/3]

constexpr blender::IndexRange::IndexRange ( int64_t  size)
inlineexplicitconstexpr

Definition at line 73 of file BLI_index_range.hh.

References BLI_assert, and size().

◆ IndexRange() [3/3]

constexpr blender::IndexRange::IndexRange ( int64_t  start,
int64_t  size 
)
inlineconstexpr

Definition at line 78 of file BLI_index_range.hh.

References BLI_assert, size(), and start().

Member Function Documentation

◆ after()

constexpr IndexRange blender::IndexRange::after ( int64_t  n) const
inlineconstexpr

Create a new range starting at the end of the current one.

Definition at line 168 of file BLI_index_range.hh.

References BLI_assert, and IndexRange().

Referenced by blender::tests::TEST().

◆ as_span()

Span< int64_t > blender::IndexRange::as_span ( ) const

Get read-only access to a memory buffer that contains the range as actual numbers.

Definition at line 32 of file BLI_index_range.cc.

References blender::arrays, blender::current_array, blender::current_array_mutex, blender::current_array_size, and power_of_2_max_u().

Referenced by spreadsheet_main_region_draw(), and blender::tests::TEST().

◆ before()

constexpr IndexRange blender::IndexRange::before ( int64_t  n) const
inlineconstexpr

Create a new range that ends at the start of the current one.

Definition at line 177 of file BLI_index_range.hh.

References BLI_assert, and IndexRange().

Referenced by blender::tests::TEST().

◆ begin()

constexpr Iterator blender::IndexRange::begin ( ) const
inlineconstexpr

Definition at line 129 of file BLI_index_range.hh.

Referenced by blender::tests::TEST().

◆ contains()

constexpr bool blender::IndexRange::contains ( int64_t  value) const
inlineconstexpr

Returns true when the range contains a certain number, otherwise false.

Definition at line 222 of file BLI_index_range.hh.

Referenced by blender::tests::TEST().

◆ end()

constexpr Iterator blender::IndexRange::end ( ) const
inlineconstexpr

Definition at line 134 of file BLI_index_range.hh.

◆ first()

constexpr int64_t blender::IndexRange::first ( ) const
inlineconstexpr

Get the first element in the range. Asserts when the range is empty.

Definition at line 187 of file BLI_index_range.hh.

References BLI_assert, and size().

Referenced by blender::parallel_for(), and blender::tests::TEST().

◆ last()

constexpr int64_t blender::IndexRange::last ( ) const
inlineconstexpr

Get the last element in the range. Asserts when the range is empty.

Definition at line 197 of file BLI_index_range.hh.

References BLI_assert, and size().

Referenced by blender::tests::TEST().

◆ one_after_last()

constexpr int64_t blender::IndexRange::one_after_last ( ) const
inlineconstexpr

Get the element one after the end. The returned value is undefined when the range is empty.

Definition at line 206 of file BLI_index_range.hh.

Referenced by blender::parallel_for(), and blender::tests::TEST().

◆ operator[]()

constexpr int64_t blender::IndexRange::operator[] ( int64_t  index) const
inlineconstexpr

Access an element in the range.

Definition at line 142 of file BLI_index_range.hh.

References BLI_assert, and size().

◆ size()

constexpr int64_t blender::IndexRange::size ( ) const
inlineconstexpr

◆ slice() [1/2]

constexpr IndexRange blender::IndexRange::slice ( IndexRange  range) const
inlineconstexpr

Definition at line 238 of file BLI_index_range.hh.

References size(), slice(), and start().

◆ slice() [2/2]

constexpr IndexRange blender::IndexRange::slice ( int64_t  start,
int64_t  size 
) const
inlineconstexpr

Returns a new range, that contains a sub-interval of the current one.

Definition at line 230 of file BLI_index_range.hh.

References BLI_assert, IndexRange(), size(), and start().

Referenced by slice(), and blender::tests::TEST().

◆ start()

constexpr int64_t blender::IndexRange::start ( ) const
inlineconstexpr

Get the first element in the range. The returned value is undefined when the range is empty.

Definition at line 214 of file BLI_index_range.hh.

Referenced by IndexRange(), blender::Span< T >::slice(), slice(), and blender::tests::TEST().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
IndexRange  range 
)
friend

Definition at line 248 of file BLI_index_range.hh.

◆ operator==

constexpr friend bool operator== ( IndexRange  a,
IndexRange  b 
)
friend

Two ranges compare equal when they contain the same numbers.

Definition at line 152 of file BLI_index_range.hh.


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