BlockArray< T, BLOCK_SIZE_EXPONENT, MEMFLAGS, ALLOCATOR >::IteratorTemplate< CONSTITERATOR > Class Template Reference

#include <blockarray.h>

Detailed Description

template<typename T, Int BLOCK_SIZE_EXPONENT = BLOCKARRAY_DEFAULT_SIZE_EXPONENT, BLOCKARRAYFLAGS MEMFLAGS = BLOCKARRAYFLAGS::NONE, typename ALLOCATOR = DefaultAllocator>
template<Bool CONSTITERATOR>
class maxon::BlockArray< T, BLOCK_SIZE_EXPONENT, MEMFLAGS, ALLOCATOR >::IteratorTemplate< CONSTITERATOR >

The BlockArray iterator uses several tricks to make iteration faster than using a for loop with operator []. Therefore you should use it (or the C++11 range based for loop) to iterate over the array or parts of it.

You can use an iterator almost like a pointer, e.g.

it++; // go to the next element
it--; // go to the previous element
it += 5; // advance by 5 elements
it -= 3; // go back 3 elements
cnt = itB - itA; // number of elements from itA to itB
it = array.Begin(); // iterator to the first element of the array
*it = value; // assign value to the elements referenced by the iterator
value = *value; // get value of the element referenced by the iterator
PyObject * value
Definition: abstract.h:715

Public Types

using CollectionType = typename ConstIf< BlockArray, CONSTITERATOR >::type
 
using Type = typename ConstIf< T, CONSTITERATOR >::type
 

Public Member Functions

 IteratorTemplate (CollectionType &a, Int start=0)
 
 IteratorTemplate (CollectionType *a, Int blockIdx, Int localIdx)
 
 IteratorTemplate (CollectionType *a=nullptr, BlockType *block=nullptr, BlockIterator it=BlockIterator(), BlockIterator end=BlockIterator())
 
 IteratorTemplate (const IteratorTemplate &src)
 
IteratorTemplateoperator= (const IteratorTemplate &src)
 
 operator ConstIterator & ()
 
template<Bool STRIDED>
MAXON_ATTRIBUTE_FORCE_INLINE IteratorTemplate GetBlock (Block< Type, STRIDED > &block) const
 
Int GetBlockIndexAndLocalIndex (Int &localIdx) const
 
 operator Bool () const
 
TypeGetPtr () const
 
Typeoperator* () const
 
Typeoperator-> () const
 
Bool operator== (const IteratorTemplate &b) const
 
Bool operator< (const IteratorTemplate &b) const
 
 MAXON_OPERATOR_COMPARISON (IteratorTemplate)
 
IteratorTemplateoperator++ ()
 
const IteratorTemplate operator++ (int)
 
IteratorTemplateoperator+= (Int i)
 
IteratorTemplate operator+ (Int i) const
 
IteratorTemplateoperator-- ()
 
const IteratorTemplate operator-- (int)
 
IteratorTemplateoperator-= (Int i)
 
IteratorTemplate operator- (Int i) const
 
Int operator- (const IteratorTemplate &b) const
 

Static Public Attributes

static const Bool isLinearIterator
 

Private Types

using BlockIterator = typename std::conditional< CONSTITERATOR, typename ArrayBlock::ConstIterator, typename ArrayBlock::Iterator >::type
 
using BlockType = typename ConstIf< ArrayBlock, CONSTITERATOR >::type
 

Private Attributes

CollectionType_array
 
BlockType_block
 
BlockIterator _iterator
 
BlockIterator _end
 

Member Typedef Documentation

◆ BlockIterator

using BlockIterator = typename std::conditional<CONSTITERATOR, typename ArrayBlock::ConstIterator, typename ArrayBlock::Iterator>::type
private

◆ BlockType

using BlockType = typename ConstIf<ArrayBlock, CONSTITERATOR>::type
private

◆ CollectionType

using CollectionType = typename ConstIf<BlockArray, CONSTITERATOR>::type

◆ Type

using Type = typename ConstIf<T, CONSTITERATOR>::type

Constructor & Destructor Documentation

◆ IteratorTemplate() [1/4]

IteratorTemplate ( CollectionType a,
Int  start = 0 
)
explicit

◆ IteratorTemplate() [2/4]

IteratorTemplate ( CollectionType a,
Int  blockIdx,
Int  localIdx 
)
explicit

◆ IteratorTemplate() [3/4]

IteratorTemplate ( CollectionType a = nullptr,
BlockType block = nullptr,
BlockIterator  it = BlockIterator(),
BlockIterator  end = BlockIterator() 
)
explicit

◆ IteratorTemplate() [4/4]

IteratorTemplate ( const IteratorTemplate< CONSTITERATOR > &  src)

Member Function Documentation

◆ operator=()

IteratorTemplate& operator= ( const IteratorTemplate< CONSTITERATOR > &  src)

◆ operator ConstIterator &()

operator ConstIterator & ( )

◆ GetBlock()

MAXON_ATTRIBUTE_FORCE_INLINE IteratorTemplate GetBlock ( Block< Type, STRIDED > &  block) const

Determines a contiguous block of array elements to which the iterator points.

Parameters
[out]blockBlock which contains the element..
Returns
Start iterator of the block.

◆ GetBlockIndexAndLocalIndex()

Int GetBlockIndexAndLocalIndex ( Int localIdx) const

◆ operator Bool()

operator Bool ( ) const
explicit
Returns
true if the iterator points to an element.

◆ GetPtr()

Type* GetPtr ( void  ) const

◆ operator*()

Type& operator* ( ) const

◆ operator->()

Type* operator-> ( void  ) const

◆ operator==()

Bool operator== ( const IteratorTemplate< CONSTITERATOR > &  b) const

◆ operator<()

Bool operator< ( const IteratorTemplate< CONSTITERATOR > &  b) const

◆ MAXON_OPERATOR_COMPARISON()

MAXON_OPERATOR_COMPARISON ( IteratorTemplate< CONSTITERATOR >  )

◆ operator++() [1/2]

IteratorTemplate& operator++ ( )

◆ operator++() [2/2]

const IteratorTemplate operator++ ( int  )

◆ operator+=()

IteratorTemplate& operator+= ( Int  i)

◆ operator+()

IteratorTemplate operator+ ( Int  i) const

◆ operator--() [1/2]

IteratorTemplate& operator-- ( )

◆ operator--() [2/2]

const IteratorTemplate operator-- ( int  )

◆ operator-=()

IteratorTemplate& operator-= ( Int  i)

◆ operator-() [1/2]

IteratorTemplate operator- ( Int  i) const

◆ operator-() [2/2]

Int operator- ( const IteratorTemplate< CONSTITERATOR > &  b) const

Member Data Documentation

◆ isLinearIterator

const Bool isLinearIterator
static

◆ _array

CollectionType* _array
private

◆ _block

BlockType* _block
private

◆ _iterator

BlockIterator _iterator
private

◆ _end

BlockIterator _end
private