![]() |
Implementation of an iterator for pointer vectors.The PtrIterator class follows the example of the random-access iterator classes of the STL. However, the focus of this iterator implementation is the use with (polymorphic) pointers. The implementation of the Blaze library eases the use of iterators over a range of pointers and improves the semantics on these pointers.
.
More...
#include <PtrIterator.h>
Public Types | |
typedef std::random_access_iterator_tag | IteratorCategory |
The iterator category. | |
typedef Type * | ValueType |
Type of the underlying pointers. | |
typedef Type * | PointerType |
Pointer return type. | |
typedef ValueType const & | ReferenceType |
Reference return type. | |
typedef ValueType const * | IteratorType |
Type of the internal pointer. | |
typedef std::ptrdiff_t | DifferenceType |
Difference between two iterators. | |
typedef IteratorCategory | iterator_category |
The iterator category. | |
typedef ValueType | value_type |
Type of the underlying pointers. | |
typedef PointerType | pointer |
Pointer return type. | |
typedef ReferenceType | reference |
Reference return type. | |
typedef DifferenceType | difference_type |
Difference between two iterators. | |
Public Member Functions | |
Constructors | |
PtrIterator () | |
Default constructor for PtrIterator. | |
PtrIterator (const IteratorType &it) | |
Standard constructor for PtrIterator. More... | |
template<typename Other > | |
PtrIterator (const PtrIterator< Other > &it) | |
Conversion constructor from different PtrIterator instances. More... | |
Operators | |
PtrIterator & | operator++ () |
Pre-increment operator. More... | |
PtrIterator | operator++ (int) |
Post-increment operator. More... | |
PtrIterator & | operator-- () |
Pre-decrement operator. More... | |
PtrIterator | operator-- (int) |
Post-decrement operator. More... | |
PtrIterator & | operator+= (DifferenceType n) |
Shifting the iterator by n elements to the higher elements. More... | |
PtrIterator | operator+ (DifferenceType n) const |
Shifting the iterator by n elements to the higher elements. More... | |
PtrIterator & | operator-= (DifferenceType n) |
Shifting the iterator by n elements to the lower elements. More... | |
PtrIterator | operator- (DifferenceType n) const |
Shifting the iterator by n elements to the lower elements. More... | |
DifferenceType | operator- (const PtrIterator &it) const |
Calculating the number of elements between two pointer iterators. More... | |
Access operators | |
PointerType | operator[] (DifferenceType n) const |
Subscript operator for the direct element access. More... | |
PointerType | operator* () const |
Returns a handle to the element at the current iterator position. More... | |
PointerType | operator-> () const |
Direct access to the element at the current iterator position. More... | |
Utility functions | |
const IteratorType & | base () const |
Access to the underlying member of the pointer iterator. More... | |
Private Attributes | |
Member variables | |
IteratorType | it_ |
Pointer to the current memory location. | |
Implementation of an iterator for pointer vectors.
The PtrIterator class follows the example of the random-access iterator classes of the STL. However, the focus of this iterator implementation is the use with (polymorphic) pointers. The implementation of the Blaze library eases the use of iterators over a range of pointers and improves the semantics on these pointers.
.
In contrast to the STL iterators, the PtrIterator class slightly changes the meaning of the access operators. Consider the following example:
The constant iterators (iterator over constant objects) prohibit the access to non-const member functions. Therefore the following operation results in a compile-time error:
|
inlineexplicit |
Standard constructor for PtrIterator.
it | The value of the iterator. |
|
inline |
Conversion constructor from different PtrIterator instances.
it | The foreign PtrIterator instance to be copied. |
|
inline |
Access to the underlying member of the pointer iterator.
|
inline |
Returns a handle to the element at the current iterator position.
|
inline |
Shifting the iterator by n elements to the higher elements.
n | The number of elements. |
|
inline |
Pre-increment operator.
|
inline |
Post-increment operator.
|
inline |
Shifting the iterator by n elements to the higher elements.
n | The number of elements. |
|
inline |
Shifting the iterator by n elements to the lower elements.
n | The number of elements. |
|
inline |
Calculating the number of elements between two pointer iterators.
it | The right hand side iterator. |
|
inline |
Pre-decrement operator.
|
inline |
Post-decrement operator.
|
inline |
Shifting the iterator by n elements to the lower elements.
n | The number of elements. |
|
inline |
Direct access to the element at the current iterator position.
|
inline |
Subscript operator for the direct element access.
index | Access index. Accesses the element index elements away from the current iterator position. |