Lumiera  0.pre.03
»edit your freedom«
iter-adapter-stl.hpp File Reference

Go to the source code of this file.

Description

Preconfigured adapters for some STL container standard usage situations.

Especially, definitions for accessing views on common STL containers repackaged as lumiera forward iterators. Mostly the purpose is ease of use, we don't create an abstraction barrier or try to hide implementation details. (see iter-source.hpp for such an abstraction facility). As a benefit, these adapters can be considered low overhead.

See also
iter-adapter-stl-test.cpp
iter-adapter.hpp
iter-source.happ
intertools.hpp

Definition in file iter-adapter-stl.hpp.

#include "lib/iter-adapter.hpp"
#include "lib/iter-adapter-ptr-deref.hpp"
#include <vector>

Classes

struct  _MapIterT< IT >
 
struct  _MapSubSelector< IT, SEL >
 helper to access the parts of the pair values correctly... More...
 
struct  _MapSubSelector< IT, SEL const & >
 especially for const iterators we need to use const& and const* More...
 
struct  _MapT< MAP >
 
struct  _MapTypeSelector< MAP >
 
struct  _MapTypeSelector< const MAP >
 
struct  _SeqT< SEQ >
 
struct  _SeqT< const SEQ >
 
class  DistinctIter< IT >
 Helper to filter repeated values from a wrapped iterator (both STL or Lumiera) More...
 
class  IterSnapshot< VAL >
 materialised iterator contents. More...
 
struct  Wrapped_Identity< IT >
 Wrapped-Iter-Policy: forwarding directly with typing retained unaltered. More...
 
struct  Wrapped_PickConstVal< IT >
 
struct  Wrapped_PickKey< IT >
 Wrapped-Iter-Policy: picking the key part of a pair iterator (map or multimap). More...
 
struct  Wrapped_PickVal< IT >
 Wrapped-Iter-Policy: picking the value part of a pair iterator (map or multimap). More...
 
struct  WrappedStlIter< DEF >
 helper baseclass to simplify defining customised wrapped STL iterators More...
 

Typedefs

template<class CON >
using ContentSnapshot = IterSnapshot< typename CON::value_type >
 

Functions

template<class IT >
ContentSnapshot< IT > dischargeToSnapshot (IT &ii)
 Take a snapshot of the given LumieraIterator, which is thereby consumed. More...
 
template<class CON >
_SeqT< CON >::Addrs eachAddress (CON &coll)
 
template<class SEQ >
_SeqT< SEQ >::DistinctVals eachDistinct (SEQ &seq)
 build a Lumiera Forward Iterator to suppress any repetitions in the given sequence.
 
template<class MAP >
_MapT< MAP >::DistinctKeys eachDistinctKey (MAP &map)
 
template<class CON >
_SeqT< CON >::Range eachElm (CON &coll)
 
template<class MAP >
_MapT< MAP >::KeyIter eachKey (MAP &map)
 
template<class IT >
_MapIterT< IT >::KeyIter eachKey (IT const &begin, IT const &end)
 
template<class MAP >
_MapT< MAP >::ValIter eachVal (MAP &map)
 
template<class IT >
_MapIterT< IT >::ValIter eachVal (IT const &begin, IT const &end)
 
template<class MMAP , typename KEY >
_MapT< MMAP >::ValIter eachValForKey (MMAP &multimap, KEY key)
 
template<class CON >
ContentSnapshot< CON > snapshot (CON const &con)
 Take a snapshot of the given STL compliant container. More...
 
template<class VAL >
iter_stl::IterSnapshot< VAL > snapshot (std::initializer_list< VAL > const &&ili)
 Take a snapshot of the given std::initializer_list. More...
 

Namespaces

 lib
 Implementation namespace for support and library code.
 

Class Documentation

◆ lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapIterT

struct lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapIterT
Class Members
typedef IT EntryIter
typedef first_type KeyType
typedef second_type ValType
typedef reference DetectConst
typedef _MapSubSelector
< EntryIter, DetectConst >
::PickKey
PickKeyIter
typedef _MapSubSelector
< EntryIter, DetectConst >
::PickVal
PickValIter
typedef RangeIter< PickKeyIter > KeyIter
typedef RangeIter< PickValIter > ValIter
typedef DistinctIter< KeyIter > DistinctKeys
+ Collaboration diagram for _MapIterT< IT >:

◆ lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapSubSelector

struct lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapSubSelector
Class Members
typedef WrappedStlIter
< Wrapped_PickKey< IT > >
PickKey
typedef WrappedStlIter
< Wrapped_PickVal< IT > >
PickVal
+ Collaboration diagram for _MapSubSelector< IT, SEL >:

◆ lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapSubSelector< IT, SEL const & >

struct lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapSubSelector< IT, SEL const & >
Class Members
typedef WrappedStlIter
< Wrapped_PickKey< IT > >
PickKey
typedef WrappedStlIter
< Wrapped_PickConstVal< IT > >
PickVal
+ Collaboration diagram for _MapSubSelector< IT, SEL const & >:

◆ lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapT

struct lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapT
Class Members
typedef _MapTypeSelector< MAP >
::Key
KeyType
typedef _MapTypeSelector< MAP >
::Val
ValType
typedef _MapTypeSelector< MAP >
::Itr
EntryIter
typedef reference DetectConst
typedef _MapSubSelector
< EntryIter, DetectConst >
::PickKey
PickKeyIter
typedef _MapSubSelector
< EntryIter, DetectConst >
::PickVal
PickValIter
typedef RangeIter< PickKeyIter > KeyIter
typedef RangeIter< PickValIter > ValIter
typedef DistinctIter< KeyIter > DistinctKeys
+ Collaboration diagram for _MapT< MAP >:

◆ lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapTypeSelector

struct lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapTypeSelector
Class Members
typedef first_type Key
typedef second_type Val
typedef iterator Itr
+ Collaboration diagram for _MapTypeSelector< MAP >:

◆ lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapTypeSelector< const MAP >

struct lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_MapTypeSelector< const MAP >
Class Members
typedef first_type Key
typedef second_type const Val
typedef const_iterator Itr
+ Collaboration diagram for _MapTypeSelector< const MAP >:

◆ lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_SeqT

struct lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_SeqT
Class Members
typedef iterator Iter
typedef RangeIter< Iter > Range
typedef DistinctIter< Range > DistinctVals
typedef AddressExposingIter
< Range >
Addrs
+ Collaboration diagram for _SeqT< SEQ >:

◆ lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_SeqT< const SEQ >

struct lib::iter_stl::anonymous_namespace{iter-adapter-stl.hpp}::_SeqT< const SEQ >
Class Members
typedef const_iterator Iter
typedef RangeIter< Iter > Range
typedef DistinctIter< Range > DistinctVals
typedef AddressExposingIter
< Range >
Addrs
+ Collaboration diagram for _SeqT< const SEQ >:

Function Documentation

◆ eachElm()

_SeqT<CON>::Range lib::iter_stl::eachElm ( CON &  coll)
inline
Returns
Lumiera Forward Iterator to yield each Element from a STL container

Definition at line 294 of file iter-adapter-stl.hpp.

References lib::iter_stl::eachElm().

Referenced by lib::iter_stl::eachAddress(), and lib::iter_stl::eachElm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eachAddress()

_SeqT<CON>::Addrs lib::iter_stl::eachAddress ( CON &  coll)
inline
Returns
Lumiera Forward Iterator exposing the address of each Element within a STL

Definition at line 306 of file iter-adapter-stl.hpp.

References lib::iter_stl::eachAddress(), and lib::iter_stl::eachElm().

Referenced by lib::iter_stl::eachAddress().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eachKey() [1/2]

_MapT<MAP>::KeyIter lib::iter_stl::eachKey ( MAP &  map)
inline
Returns
Lumiera Forward Iterator to yield each key of a map/multimap

Definition at line 318 of file iter-adapter-stl.hpp.

References lib::iter_stl::eachKey().

Referenced by lib::iter_stl::eachDistinctKey(), and lib::iter_stl::eachKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eachKey() [2/2]

_MapIterT<IT>::KeyIter lib::iter_stl::eachKey ( IT const &  begin,
IT const &  end 
)
inline
Returns
Lumiera Forward Iterator extracting the keys from a given range of (key,value) pairs

Definition at line 332 of file iter-adapter-stl.hpp.

References lib::iter_stl::eachKey().

+ Here is the call graph for this function:

◆ eachVal() [1/2]

_MapT<MAP>::ValIter lib::iter_stl::eachVal ( MAP &  map)
inline
Returns
Lumiera Forward Iterator to yield each value within a map/multimap

Definition at line 346 of file iter-adapter-stl.hpp.

References lib::iter_stl::eachVal().

Referenced by lib::iter_stl::eachVal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eachVal() [2/2]

_MapIterT<IT>::ValIter lib::iter_stl::eachVal ( IT const &  begin,
IT const &  end 
)
inline
Returns
Lumiera Forward Iterator extracting the values from a given range of (key,value) pairs

Definition at line 360 of file iter-adapter-stl.hpp.

References lib::iter_stl::eachVal().

+ Here is the call graph for this function:

◆ eachDistinctKey()

_MapT<MAP>::DistinctKeys lib::iter_stl::eachDistinctKey ( MAP &  map)
inline
Returns
Lumiera Forward Iterator to yield the distinct keys from a multimap
Warning
full scan of all keys, dropping repetitions

Definition at line 389 of file iter-adapter-stl.hpp.

References lib::iter_stl::eachDistinctKey(), and lib::iter_stl::eachKey().

Referenced by lib::iter_stl::eachDistinctKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eachValForKey()

_MapT<MMAP>::ValIter lib::iter_stl::eachValForKey ( MMAP &  multimap,
KEY  key 
)
inline
Returns
Lumiera Forward Iterator to yield the distinct keys from a multimap
Warning
full scan of all keys, dropping repetitions

Definition at line 401 of file iter-adapter-stl.hpp.

References lib::iter_stl::eachValForKey().

Referenced by lib::iter_stl::eachValForKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snapshot() [1/2]

ContentSnapshot<CON> lib::iter_stl::snapshot ( CON const &  con)
inline

Take a snapshot of the given STL compliant container.

Returns
Lumiera Forward Iterator to yield each Element from this snapshot
Note
the snapshot is stored within a vector, i.e. heap allocated.
Warning
copying the returned iterator object copies the snapshot vector

Definition at line 578 of file iter-adapter-stl.hpp.

References lib::iter_stl::snapshot().

Referenced by lib::iter_stl::snapshot().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dischargeToSnapshot()

ContentSnapshot<IT> lib::iter_stl::dischargeToSnapshot ( IT &  ii)
inline

Take a snapshot of the given LumieraIterator, which is thereby consumed.

Returns
Lumiera Forward Iterator to yield each Element from this snapshot

Definition at line 588 of file iter-adapter-stl.hpp.

References lib::iter_stl::dischargeToSnapshot().

Referenced by lib::iter_stl::dischargeToSnapshot().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ snapshot() [2/2]

iter_stl::IterSnapshot<VAL> lib::iter_stl::snapshot ( std::initializer_list< VAL > const &&  ili)
inline

Take a snapshot of the given std::initializer_list.

Returns
Lumiera Forward Iterator to yield each Element from this snapshot
Remarks
this can be a easy workaround for passing on a sequence of literal values defined inline in a brace expression; the typical implementation of brace initialiser lists allocates a temporary array on the stack. By using this helper, we copy the elements from this local array into a vector on the heap. Of course this isn't efficient, but it's convenient, e.g. for testing.

Definition at line 604 of file iter-adapter-stl.hpp.

References lib::iter_stl::snapshot().

+ Here is the call graph for this function: