Evo C++ Library v0.5.1
|
#include <evo/impl/iter.h>
Random access iterator.
Used to iterate through container items.
T | Container type (must not be const) |
Iterators work like normal pointers.
Containers normally define iterator types via member typedefs with const and mutable (non-const) variations, normally named Iter (const) and IterM (mutable). The iterator key type is stored by the iterator as a handle and is used to implement the iterator.
Example:
Iterators interact with containers using an expected interface implemented by the container – this is used internally:
Public Types | |
typedef IteratorRa< const T > | Const |
Random access const iterator type. More... | |
typedef IteratorBase< T >::Item | Item |
Iterator item type. More... | |
typedef IteratorBase< T > | IterBaseType |
Iterator base type for parameter passing. More... | |
typedef IteratorRa< T > | IterType |
Iterator type. More... | |
typedef IteratorBase< T >::Key | Key |
Iterator key type. More... | |
typedef IteratorRa< typename RemoveConst< T >::Type > | Mutable |
Random access mutable iterator type. More... | |
typedef IteratorBase< T >::Size | Size |
Size type to use. More... | |
typedef T | Target |
Iterator target type. More... | |
typedef StaticIf< IsConst< T >::value, Mutable, Const >::Type | ToggleConst |
Used for converting between Const/Mutable iterators. More... | |
Public Member Functions | |
IteratorRa () | |
Constructor. More... | |
IteratorRa (T &obj) | |
Constructor. More... | |
IteratorRa (T &obj, IteratorPos pos) | |
Constructor setting position. More... | |
IteratorRa (T &obj, Key num) | |
Constructor setting position. More... | |
IteratorRa (T &obj, const Key &key, Item *data) | |
Constructor. More... | |
IteratorRa (const IterType &src) | |
Copy constructor. More... | |
IteratorRa (const IterBaseType &src) | |
Copy constructor. More... | |
int | compare (const IterBaseType &iter) const |
Compare to another iterator. More... | |
int | compare (Key num) const |
Compare to a position index. More... | |
Size | count () const |
Get container item count. More... | |
Key | index () const |
Get iterator position index. More... | |
operator SafeBoolType () const | |
Safe (explicit) evaluation as bool type. More... | |
bool | operator! () const |
Check whether iterator is at end (not valid). More... | |
bool | operator!= (const IterBaseType &iter) const |
Inequality operator. More... | |
template<typename T_ > | |
bool | operator!= (const IteratorBase< T_ > &oth) const |
Check inequality with another iterator. More... | |
bool | operator!= (Key num) const |
Inequality operator. More... | |
Item & | operator* () |
Dereference iterator to get item data reference. More... | |
IterType | operator+ (Size count) const |
Addition (multi increment) operator. More... | |
IterType & | operator++ () |
Pre increment operator. More... | |
IterType | operator++ (int) |
Post increment operator. More... | |
IterType & | operator+= (Size count) |
In-place addition (multi increment) operator. More... | |
IterType | operator- (Size count) const |
Subtraction (multi decrement) operator. More... | |
IterType & | operator-- () |
Pre decrement operator. More... | |
IterType | operator-- (int) |
Post decrement operator. More... | |
IterType & | operator-= (Size count) |
In-place subtraction (multi decrement) operator. More... | |
Item * | operator-> () |
Dereference iterator to access data member. More... | |
bool | operator< (const IterBaseType &iter) const |
Less-than operator. More... | |
bool | operator< (Key num) const |
Less-than operator. More... | |
bool | operator<= (const IterBaseType &iter) const |
Less-than-or-equal operator. More... | |
bool | operator<= (Key num) const |
Less-than-or-equal operator. More... | |
IterType & | operator= (const IterType &src) |
Copy/Assignment operator to copy from source iterator. More... | |
IterType & | operator= (const IterBaseType &src) |
Copy/Assignment operator to copy from source iterator. More... | |
IterType & | operator= (const ToggleConst &src) |
Assignment operator to copy from source iterator. More... | |
IterType & | operator= (const typename IterBaseType::ToggleConst &src) |
Assignment operator to copy from source iterator. More... | |
IterType & | operator= (T &obj) |
Assignment operator. More... | |
IterType & | operator= (IteratorPos pos) |
Assignment operator to set position. More... | |
IterType & | operator= (Key num) |
Assignment operator for random access position index. More... | |
bool | operator== (const IterBaseType &iter) const |
Equality operator. More... | |
template<typename T_ > | |
bool | operator== (const IteratorBase< T_ > &oth) const |
Check equality with another iterator. More... | |
bool | operator== (Key num) const |
Equality operator. More... | |
bool | operator> (const IterBaseType &iter) const |
Greater-than operator. More... | |
bool | operator> (Key num) const |
Greater-than operator. More... | |
bool | operator>= (const IterBaseType &iter) const |
Greater-than-or-equal operator. More... | |
bool | operator>= (Key num) const |
Greater-than-or-equal operator. More... | |
Static Public Member Functions | |
static const IterBaseType & | end () |
Get iterator at end position. More... | |
Protected Member Functions | |
bool | first () |
Go to first item (used internally). More... | |
bool | last () |
Go to last item. More... | |
bool | next () |
Go to next item (used internally). More... | |
bool | next (Size count) |
Go to next item, skipping given count (used internally). More... | |
bool | prev () |
Go to previous item. More... | |
bool | prev (Size count) |
Go to previous item, skipping given count (used internally). More... | |
Protected Attributes | |
Item * | data_ |
Item pointer. More... | |
bool | end_ |
End flag. More... | |
Key | key_ |
Iterator key. More... | |
T * | obj_ |
Container object pointer. More... | |
typedef IteratorRa<const T> Const |
Random access const iterator type.
typedef IteratorBase<T>::Item Item |
Iterator item type.
typedef IteratorBase<T> IterBaseType |
Iterator base type for parameter passing.
typedef IteratorRa<T> IterType |
Iterator type.
typedef IteratorBase<T>::Key Key |
Iterator key type.
typedef IteratorRa<typename RemoveConst<T>::Type> Mutable |
Random access mutable iterator type.
typedef IteratorBase<T>::Size Size |
Size type to use.
|
inherited |
Iterator target type.
typedef StaticIf<IsConst<T>::value,Mutable,Const>::Type ToggleConst |
Used for converting between Const/Mutable iterators.
|
inline |
Constructor.
This sets empty iterator at end.
|
inlineexplicit |
Constructor.
This sets iterator to first item (or end if empty).
obj | Container object for iterator |
|
inlineexplicit |
Constructor setting position.
This sets iterator to given position (or end if empty).
obj | Container object for iterator |
pos | Position to set, either iterFIRST, iterLAST, or iterEND |
|
inline |
Constructor setting position.
This sets iterator to given position (or end if empty).
obj | Container object for iterator |
num | Position index to set |
|
inline |
Constructor.
This initializes iterator with given position data (used internally).
obj | Container object for iterator |
key | Iterator key to set |
data | Iterator data pointer to set |
|
inline |
Copy constructor.
src | Source iterator to copy |
|
inline |
Copy constructor.
src | Source iterator to copy |
|
inline |
Compare to another iterator.
iter | Iterator to compare |
|
inline |
Compare to a position index.
num | Position index to compare, END for end position |
|
inline |
Get container item count.
|
inlinestaticinherited |
Get iterator at end position.
|
inlineprotectedinherited |
Go to first item (used internally).
|
inline |
Get iterator position index.
|
inlineprotectedinherited |
Go to last item.
|
inlineprotectedinherited |
Go to next item (used internally).
|
inlineprotected |
Go to next item, skipping given count (used internally).
count | Number of items to advance |
|
inlineinherited |
Safe (explicit) evaluation as bool type.
|
inlineinherited |
Check whether iterator is at end (not valid).
|
inlineinherited |
Inequality operator.
iter | Iterator to compare |
|
inlineinherited |
Check inequality with another iterator.
oth | Other iterator to check against. |
Inequality operator.
num | Position index to compare |
|
inlineinherited |
Dereference iterator to get item data reference.
Addition (multi increment) operator.
Same as next(Size) on the returned temporary iterator.
count | Count to add |
|
inlineinherited |
Post increment operator.
Same as next(), but returns iterator copy before increment.
In-place addition (multi increment) operator.
Same as next(Size).
count | Count to add |
Subtraction (multi decrement) operator.
Same as prev(Size) on the returned temporary iterator.
count | Count to subtract |
|
inlineinherited |
Post decrement operator.
Same as prev(), but returns iterator copy before decrement.
In-place subtraction (multi decrement) operator.
Same as prev(Size).
count | Count to subtract |
|
inlineinherited |
Dereference iterator to access data member.
|
inline |
Less-than operator.
iter | Iterator to compare |
|
inline |
Less-than operator.
num | Position index to compare |
|
inline |
Less-than-or-equal operator.
iter | Iterator to compare |
|
inline |
Less-than-or-equal operator.
num | Position index to compare |
Copy/Assignment operator to copy from source iterator.
src | Source iterator to copy |
|
inline |
Copy/Assignment operator to copy from source iterator.
src | Source iterator to copy |
|
inline |
Assignment operator to copy from source iterator.
src | Source iterator to copy. |
|
inline |
Assignment operator to copy from source iterator.
src | Source iterator to copy. |
|
inline |
Assignment operator.
This sets iterator to first item (or end if empty).
obj | Container object to iterate through |
|
inline |
Assignment operator to set position.
pos | Position to set, either iterFIRST, iterLAST, or iterEND |
Assignment operator for random access position index.
num | Iterator index to set |
|
inlineinherited |
Equality operator.
iter | Iterator to compare |
|
inlineinherited |
Check equality with another iterator.
oth | Other iterator to check against. |
|
inline |
Equality operator.
num | Position index to compare |
|
inline |
Greater-than operator.
iter | Iterator to compare |
|
inline |
Greater-than operator.
num | Position index to compare |
|
inline |
Greater-than-or-equal operator.
iter | Iterator to compare |
|
inline |
Greater-than-or-equal operator.
num | Position index to compare |
|
inlineprotectedinherited |
Go to previous item.
|
inlineprotected |
Go to previous item, skipping given count (used internally).
count | Number of items to advance |
|
protectedinherited |
Item pointer.
|
protectedinherited |
End flag.
|
protectedinherited |
Iterator key.
|
protectedinherited |
Container object pointer.