#include <baselist.h>
The BaseList iterator internally is a pointer to the NODE containing the data of type T and using it to iterate over a list or parts of it is as efficient as using a real pointer to the list nodes (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.
Public Types | |
using | CollectionType = typename ConstIf< BaseList, CONSTITERATOR >::type |
using | Type = typename ConstIf< T, CONSTITERATOR >::type |
using | NodeType = typename ConstIf< NODE, CONSTITERATOR >::type |
Public Member Functions | |
IteratorTemplate (CollectionType &l) | |
IteratorTemplate (NodeType *pos=nullptr) | |
IteratorTemplate (const IteratorTemplate &src) | |
IteratorTemplate & | operator= (const IteratorTemplate &src) |
operator ConstIterator & () | |
Type * | GetPtr () const |
operator Bool () const | |
Type & | operator* () const |
Type * | operator-> () const |
Bool | operator== (const IteratorTemplate &b) const |
Bool | operator!= (const IteratorTemplate &b) const |
IteratorTemplate & | operator++ () |
const IteratorTemplate | operator++ (int) |
IteratorTemplate & | operator-- () |
const IteratorTemplate | operator-- (int) |
IteratorTemplate & | operator+= (Int i) |
IteratorTemplate | operator+ (Int i) const |
IteratorTemplate & | operator-= (Int i) |
IteratorTemplate | operator- (Int i) const |
Int | operator- (const IteratorTemplate &b) const |
NodeType * | GetNode () const |
Static Public Attributes | |
static const Bool | isLinearIterator |
Private Attributes | |
NodeType * | _node |
using CollectionType = typename ConstIf<BaseList, CONSTITERATOR>::type |
|
explicit |
|
explicit |
IteratorTemplate | ( | const IteratorTemplate< CONSTITERATOR > & | src | ) |
IteratorTemplate& operator= | ( | const IteratorTemplate< CONSTITERATOR > & | src | ) |
operator ConstIterator & | ( | ) |
Type* GetPtr | ( | ) | const |
|
explicit |
Type& operator* | ( | ) | const |
Type* operator-> | ( | ) | const |
Bool operator== | ( | const IteratorTemplate< CONSTITERATOR > & | b | ) | const |
Bool operator!= | ( | const IteratorTemplate< CONSTITERATOR > & | b | ) | const |
IteratorTemplate& operator++ | ( | ) |
const IteratorTemplate operator++ | ( | int | ) |
IteratorTemplate& operator-- | ( | ) |
const IteratorTemplate operator-- | ( | int | ) |
IteratorTemplate& operator+= | ( | Int | i | ) |
IteratorTemplate operator+ | ( | Int | i | ) | const |
IteratorTemplate& operator-= | ( | Int | i | ) |
IteratorTemplate operator- | ( | Int | i | ) | const |
Int operator- | ( | const IteratorTemplate< CONSTITERATOR > & | b | ) | const |
NodeType* GetNode | ( | ) | const |
|
static |