Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Helper template(s) for creating Lumiera Forward Iterators.
These are the foundation to build up iterator like types from scratch. Usually, these templates will be created and provided by a custom container type and accessed by the client through a typedef name "`iterator`" (similar to the usage within the STL). For more advanced usage, the providing container might want to subclass these iterators, e.g. to provide an additional, specialised API.
Depending on the concrete situation, several flavours are provided:
Some more specific use cases are provided in the extension header iter-adapter-ptr-deref.hpp
There are many further ways of building a Lumiera Forward Iterator. For example, lib::IterSource exposes a "iterable" source of data elements, while hiding the actual container or generator implementation behind a VTable call. Furthermore, complex processing chains with recursive expansion can be built with the IterExporer builder function. Besides, there are adapters for the most common usages with STL containers, and such iterators can also be combined and extended with the help of itertools.hpp
Basically every class in compliance with our specific iterator concept can be used as a building block within this framework.
Similar to the STL, instead of using a common "Iterator" base class, we rather define a common set of functions and behaviour which can be expected from any such iterator. These rules are similar to STL's "forward iterator", with the addition of an bool check to detect iteration end. The latter is inspired by the hasNext()
function found in many current languages supporting iterators. In a similar vein (inspired from functional programming), we deliberately don't support the various extended iterator concepts from STL and boost (random access iterators, output iterators, arithmetics, difference between iterators and the like). According to this concept, an iterator is a promise for pulling values, and nothing beyond that.
Definition in file iter-adapter.hpp.
Classes | |
class | CheckedCore< COR > |
Adapter to add sanity checks to a »state core«. More... | |
class | ConstIter< IT > |
wrapper to expose values as const More... | |
class | IterableDecorator< T, COR > |
Decorator-Adapter to make a »state core« iterable as Lumiera Forward Iterator. More... | |
class | IterAdapter< POS, CON > |
Adapter for building an implementation of the »Lumiera Forward Iterator« concept. More... | |
class | IterStateCore< IT > |
Adapter to dress up an existing »Lumiera Forward Iterator« as »state core«. More... | |
class | IterStateWrapper< T, ST > |
Another Lumiera Forward Iterator building block, based on incorporating a state type right into the iterator. More... | |
struct | IterType< TY > |
Helper for type rewritings: get the element type for an iterator like entity. More... | |
struct | IterType< Iter< TY, CON > > |
struct | IterType< RangeIter< IT > > |
class | NumIter< INT > |
Enumerate all "numbers" within a range. More... | |
class | RangeIter< IT > |
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapter is completely self-contained and allows to iterate once over the range of elements, until pos==end . More... | |
struct | IterType< RangeIter< IT > >::SimilarIter< T2 > |
< rebind to rewritten Iterator wrapped into RangeIter More... | |
struct | IterType< Iter< TY, CON > >::SimilarIter< T2 > |
< rebind to a similarly structured Iterator with value type T2 More... | |
Macros | |
#define | ENABLE_USE_IN_STD_RANGE_FOR_LOOPS(ITER) |
use a given Lumiera Forward Iterator in standard "range for loops" More... | |
#define | LIFT_PARENT_INCREMENT_OPERATOR(_BASECLASS_) |
define increment operator forwarding to baseclass but returning current More... | |
Functions | |
void | _throwIterExhausted () |
template<typename INT > | |
NumIter< INT > | eachNum (INT start, INT end) |
convenience function to iterate "each number" | |
template<class P1 , class P2 , class CON > | |
bool | operator!= (IterAdapter< P1, CON > const &il, IterAdapter< P2, CON > const &ir) |
template<class T1 , class T2 , class ST > | |
bool | operator!= (IterStateWrapper< T1, ST > const &il, IterStateWrapper< T2, ST > const &ir) |
template<class I1 , class I2 > | |
bool | operator!= (RangeIter< I1 > const &il, RangeIter< I2 > const &ir) |
template<class I1 , class I2 > | |
bool | operator!= (NumIter< I1 > const &il, NumIter< I2 > const &ir) |
template<class I1 , class I2 > | |
bool | operator!= (ConstIter< I1 > const &il, ConstIter< I2 > const &ir) |
template<class P1 , class P2 , class CON > | |
bool | operator== (IterAdapter< P1, CON > const &il, IterAdapter< P2, CON > const &ir) |
Supporting equality comparisons... | |
template<class T1 , class T2 , class ST > | |
bool | operator== (IterStateWrapper< T1, ST > const &il, IterStateWrapper< T2, ST > const &ir) |
Supporting equality comparisons of equivalent iterators (same state type)... | |
template<class I1 , class I2 > | |
bool | operator== (RangeIter< I1 > const &il, RangeIter< I2 > const &ir) |
Supporting equality comparisons... | |
template<class I1 , class I2 > | |
bool | operator== (NumIter< I1 > const &il, NumIter< I2 > const &ir) |
Supporting equality comparisons... | |
template<class I1 , class I2 > | |
bool | operator== (ConstIter< I1 > const &il, ConstIter< I2 > const &ir) |
Supporting equality comparisons... | |
Namespaces | |
lib | |
Implementation namespace for support and library code. | |
#define ENABLE_USE_IN_STD_RANGE_FOR_LOOPS | ( | ITER | ) |
use a given Lumiera Forward Iterator in standard "range for loops"
Definition at line 124 of file iter-adapter.hpp.
Referenced by ConstIter< IT >::getBase(), RangeIter< StlIter >::getPos(), NumIter< INT >::getPos(), IterableDecorator< Epoch, StorageAdaptor >::IterableDecorator(), and IterSnapshot< VAL >::IterSnapshot().
#define LIFT_PARENT_INCREMENT_OPERATOR | ( | _BASECLASS_ | ) |
define increment operator forwarding to baseclass but returning current
Definition at line 132 of file iter-adapter.hpp.
struct lib::IterType |
struct lib::IterType< Iter< TY, CON > > |
struct lib::IterType< RangeIter< IT > >::SimilarIter |