BaseArray< T, MINCHUNKSIZE, MEMFLAGS, ALLOCATOR >::IteratorTemplate< CONSTITERATOR > Class Template Reference

#include <basearray.h>

Public Types

typedef ConstIf< CONSTITERATOR, BaseArray >::Type CollectionType
 
typedef ConstIf< CONSTITERATOR, T >::Type ValueType
 

Public Member Functions

 IteratorTemplate (CollectionType &a, Int start=0)
 
 IteratorTemplate (ValueType *pos=nullptr)
 
 IteratorTemplate (const IteratorTemplate &src)
 
IteratorTemplateoperator= (const IteratorTemplate &src)
 
 operator ConstIterator & ()
 
Bool IsValid () const
 
ValueTypeGetPtr () const
 
ValueTypeoperator* () const
 
ValueTypeoperator-> () const
 
Bool operator== (const IteratorTemplate &b) const
 
Bool operator!= (const IteratorTemplate &b) const
 
Bool operator>= (const IteratorTemplate &b) const
 
Bool operator<= (const IteratorTemplate &b) const
 
Bool operator< (const IteratorTemplate &b) const
 
Bool operator> (const IteratorTemplate &b) const
 
IteratorTemplateoperator++ ()
 
const IteratorTemplate operator++ (int)
 
IteratorTemplateoperator+= (Int i)
 
IteratorTemplateoperator-- ()
 
const IteratorTemplate operator-- (int)
 
IteratorTemplateoperator-= (Int i)
 
IteratorTemplate operator+ (Int i) const
 
IteratorTemplate operator- (Int i) const
 
Int operator- (const IteratorTemplate &b) const
 

Static Public Attributes

static const Bool isLinearIterator
 

Private Attributes

ValueType_data
 

Detailed Description

template<typename T, Int MINCHUNKSIZE = BASEARRAY_DEFAULT_CHUNK_SIZE, BASEARRAYFLAGS MEMFLAGS = BASEARRAYFLAGS_0, typename ALLOCATOR = DefaultAllocator>
template<Bool CONSTITERATOR>
class cineware::BaseArray< T, MINCHUNKSIZE, MEMFLAGS, ALLOCATOR >::IteratorTemplate< CONSTITERATOR >

The BaseArray iterator internally is a pointer and using it to iterate over an array or parts of it is as efficient as using a real pointer (for more ease of use you may want to invoke this via AutoIterator).

As already said 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 = *it; // get value of the element referenced by the iterator

Please note that using a postfix operator access (*it++ or *it–) can be slower than using the prefix form or a separate assignment. E.g.

value = *it++;

is most likely slower than

value = it; ++it;

or

value = it; it++;

because *it++ requires a temporary copy of the iterator that the compiler may not be able to remove during optimization. As long as you only use the iterator's postfix operator without assignment it should be fine because the compiler will remove the temporary copy.

Member Typedef Documentation

◆ CollectionType

typedef ConstIf<CONSTITERATOR, BaseArray>::Type CollectionType

◆ ValueType

typedef ConstIf<CONSTITERATOR, T>::Type ValueType

Constructor & Destructor Documentation

◆ IteratorTemplate() [1/3]

IteratorTemplate ( CollectionType a,
Int  start = 0 
)
explicit

◆ IteratorTemplate() [2/3]

IteratorTemplate ( ValueType pos = nullptr)
explicit

◆ IteratorTemplate() [3/3]

IteratorTemplate ( const IteratorTemplate< CONSTITERATOR > &  src)

Member Function Documentation

◆ operator=()

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

◆ operator ConstIterator &()

operator ConstIterator & ( )

◆ IsValid()

Bool IsValid ( ) const
Returns
true if the iterator points to an element (Iterator().IsValid() will return false)

◆ GetPtr()

ValueType* GetPtr ( ) const

◆ operator*()

ValueType& operator* ( ) const

◆ operator->()

ValueType* operator-> ( ) const

◆ operator==()

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

◆ operator!=()

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

◆ operator>=()

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

◆ operator<=()

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

◆ operator<()

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

◆ operator>()

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

◆ operator++() [1/2]

IteratorTemplate& operator++ ( )

◆ operator++() [2/2]

const IteratorTemplate operator++ ( int  )

◆ operator+=()

IteratorTemplate& operator+= ( Int  i)

◆ 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- ( Int  i) const

◆ operator-() [2/2]

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

Member Data Documentation

◆ isLinearIterator

const Bool isLinearIterator
static

◆ _data

ValueType* _data
private