Lumiera
0.pre.03
»edit your freedom«
|
Example of a more elaborate custom container exposing an iteration API.
While the demo implementation here is based on pointers within a vector, we hand out a IterAdapter, which will call back when used by the client, thus allowing us to control the iteration process. Moreover, we provide a variant of this iterator, which automatically dereferences the pointers, thus yielding direct references for the client code to use.
Definition at line 81 of file iter-adapter-test.cpp.
Public Types | |
typedef IterAdapter< _Vec::const_iterator, const TestContainer * > | const_iterator |
typedef PtrDerefIter< const_iterator > | const_ref_iter |
typedef IterAdapter< _Vec::iterator, const TestContainer * > | iterator |
typedef PtrDerefIter< iterator > | ref_iterator |
Public Member Functions | |
TestContainer (uint count) | |
iterator | begin () |
const_iterator | begin () const |
ref_iterator | begin_ref () |
const_ref_iter | begin_ref () const |
iterator | end () |
const_iterator | end () const |
size_t | size () const |
Friends | |
template<class ITER > | |
bool | checkPoint (const TestContainer *src, ITER &pos) |
Implementation of Iteration-logic: detect iteration end. More... | |
template<class ITER > | |
void | iterNext (const TestContainer *, ITER &pos) |
Implementation of Iteration-logic: pull next element. More... | |
Private Types | |
typedef vector< int * > | _Vec |
Static Private Member Functions | |
static void | killIt (int *it) |
Private Attributes | |
_Vec | numberz_ |
|
friend |
Implementation of Iteration-logic: pull next element.
pos
is still valid_ and that the checkPoint()
function is invoked immediately afterwards, allowing to adjust pos
if necessary Definition at line 135 of file iter-adapter-test.cpp.
|
friend |
Implementation of Iteration-logic: detect iteration end.
bool(false)
. Thus, when we detect the iteration end by internal logic (numberz_.end()
), we immediately transform this into the official "bottom" Definition at line 152 of file iter-adapter-test.cpp.