#include <block.h>
The BaseIterator internally is a pointer. So 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 the C++11 range based for loop).
As already said you can use an Iterator almost like a pointer, e.g.
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.
is most likely slower than
or
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.
You can either type alias the BaseIterator (like the BaseArray does) or inherit from it.
COLLECTION | Type of the array. |
STRIDED | False for pointer-only iterator. True if the iterator has to support a variable stride offset (slower and requires another member variable). |
Classes | |
class | ResultFunctions |
Public Types | |
using | CollectionType = COLLECTION |
using | ValueType = typename InheritConst< typename COLLECTION::ValueType, COLLECTION >::type |
using | iterator_category = std::random_access_iterator_tag |
using | difference_type = Int |
using | value_type = ValueType |
using | pointer = ValueType * |
using | reference = ValueType & |
Public Member Functions | |
BaseIterator (CollectionType &a, Int start=0) | |
BaseIterator (ValueType *pos=nullptr, Int index=0, Int stride=0) | |
BaseIterator (const BaseIterator &src)=default | |
BaseIterator & | operator= (const BaseIterator &src)=default |
operator BaseIterator< typename std::add_const< COLLECTION >::type, STRIDED > & () | |
operator Bool () const | |
ValueType * | GetPtr () const |
ValueType & | operator* () const |
ValueType * | operator-> () const |
Bool | operator== (const BaseIterator &b) const |
Bool | operator< (const BaseIterator &b) const |
MAXON_OPERATOR_COMPARISON (BaseIterator) | |
BaseIterator & | operator++ () |
BaseIterator | operator++ (int) |
BaseIterator & | operator+= (Int i) |
BaseIterator & | operator-- () |
BaseIterator | operator-- (int) |
BaseIterator & | operator-= (Int i) |
BaseIterator | operator+ (Int i) const |
BaseIterator | operator- (Int i) const |
Int | operator- (const BaseIterator &b) const |
Static Public Attributes | |
static const Bool | isLinearIterator |
Protected Attributes | |
ValueType * | _data |
using CollectionType = COLLECTION |
using ValueType = typename InheritConst<typename COLLECTION::ValueType, COLLECTION>::type |
using iterator_category = std::random_access_iterator_tag |
using difference_type = Int |
using value_type = ValueType |
|
explicit |
|
explicit |
|
default |
|
default |
operator BaseIterator< typename std::add_const< COLLECTION >::type, STRIDED > & | ( | ) |
|
explicit |
ValueType* GetPtr | ( | ) | const |
ValueType& operator* | ( | ) | const |
ValueType* operator-> | ( | ) | const |
Bool operator== | ( | const BaseIterator< COLLECTION, STRIDED > & | b | ) | const |
Bool operator< | ( | const BaseIterator< COLLECTION, STRIDED > & | b | ) | const |
MAXON_OPERATOR_COMPARISON | ( | BaseIterator< COLLECTION, STRIDED > | ) |
BaseIterator& operator++ | ( | ) |
BaseIterator operator++ | ( | int | ) |
BaseIterator& operator+= | ( | Int | i | ) |
BaseIterator& operator-- | ( | ) |
BaseIterator operator-- | ( | int | ) |
BaseIterator& operator-= | ( | Int | i | ) |
BaseIterator operator+ | ( | Int | i | ) | const |
BaseIterator operator- | ( | Int | i | ) | const |
Int operator- | ( | const BaseIterator< COLLECTION, STRIDED > & | b | ) | const |
|
static |
|
protected |