40 #ifndef LIB_ITER_ADAPTER_STL_H 41 #define LIB_ITER_ADAPTER_STL_H 61 using value_type =
typename IT::value_type;
62 using reference =
typename IT::reference;
63 using pointer =
typename IT::pointer;
69 void memorise() {
if (i_) prev_ = &(*i_); }
73 DistinctIter(IT
const& i) : i_(i),prev_() { memorise(); }
75 pointer operator->()
const {
return i_; }
76 reference operator*()
const {
return *i_; }
77 bool isValid()
const {
return i_; }
90 while (i_ && prev_ && *prev_ == *i_ );
105 template<
typename DEF>
108 typedef typename DEF::Iter Iter;
109 typedef typename DEF::reference reference;
110 typedef typename DEF::pointer pointer;
116 pointer operator->()
const {
return DEF::get(i_); }
117 reference operator*()
const {
return *(DEF::get(i_)); }
135 template<
typename IT>
139 using value_type =
typename IT::value_type;
140 using reference =
typename IT::reference;
141 using pointer =
typename IT::pointer;
143 static Iter
get (Iter& it) {
return & (*it); }
150 template<
typename IT>
154 using value_type =
typename IT::value_type::first_type;
155 using reference = value_type &;
156 using pointer = value_type *;
158 static pointer
get (Iter& it) {
return & (it->first); }
165 template<
typename IT>
169 using value_type =
typename IT::value_type::second_type;
170 using reference = value_type &;
171 using pointer = value_type *;
173 static pointer
get (Iter& it) {
return & (it->second); }
176 template<
typename IT>
180 using value_type =
const typename IT::value_type::second_type;
181 using reference =
const value_type &;
182 using pointer =
const value_type *;
184 static pointer
get (Iter& it) {
return & (it->second); }
197 typedef typename MAP::value_type::first_type Key;
198 typedef typename MAP::value_type::second_type Val;
199 typedef typename MAP::iterator Itr;
205 typedef typename MAP::value_type::first_type Key;
206 typedef typename MAP::value_type::second_type
const Val;
207 typedef typename MAP::const_iterator Itr;
211 template<
class IT,
typename SEL>
219 template<
class IT,
typename SEL>
231 typedef typename _MapTypeSelector<MAP>::Key KeyType;
232 typedef typename _MapTypeSelector<MAP>::Val ValType;
233 typedef typename _MapTypeSelector<MAP>::Itr EntryIter;
235 typedef typename EntryIter::reference DetectConst;
249 typedef IT EntryIter;
251 typedef typename EntryIter::value_type::first_type KeyType;
252 typedef typename EntryIter::value_type::second_type ValType;
254 typedef typename EntryIter::reference DetectConst;
269 typedef typename SEQ::iterator Iter;
278 typedef typename SEQ::const_iterator Iter;
296 typedef typename _SeqT<CON>::Range Range;
297 return Range (coll.begin(), coll.end());
305 inline typename _SeqT<CON>::Addrs
308 typedef typename _SeqT<CON>::Addrs Addresses;
309 return Addresses (
eachElm (coll));
317 inline typename _MapT<MAP>::KeyIter
320 typedef typename _MapT<MAP>::KeyIter Range;
321 typedef typename _MapT<MAP>::PickKeyIter PickKey;
323 return Range (PickKey (map.begin()), PickKey (map.end()));
331 inline typename _MapIterT<IT>::KeyIter
334 typedef typename _MapIterT<IT>::KeyIter Range;
335 typedef typename _MapIterT<IT>::PickKeyIter PickKey;
337 return Range (PickKey (begin), PickKey (end));
345 inline typename _MapT<MAP>::ValIter
348 typedef typename _MapT<MAP>::ValIter Range;
349 typedef typename _MapT<MAP>::PickValIter PickVal;
351 return Range (PickVal (map.begin()), PickVal (map.end()));
359 inline typename _MapIterT<IT>::ValIter
362 typedef typename _MapIterT<IT>::ValIter Range;
363 typedef typename _MapIterT<IT>::PickValIter PickVal;
365 return Range (PickVal (begin), PickVal (end));
373 inline typename _SeqT<SEQ>::DistinctVals
376 typedef typename _SeqT<SEQ>::Range Range;
377 typedef typename _SeqT<SEQ>::DistinctVals DistinctValues;
379 return DistinctValues (Range (seq.begin(), seq.end()));
388 inline typename _MapT<MAP>::DistinctKeys
391 return typename _MapT<MAP>::DistinctKeys (
eachKey (map));
399 template<
class MMAP,
typename KEY>
400 inline typename _MapT<MMAP>::ValIter
403 typedef typename _MapT<MMAP>::EntryIter Pos;
404 typedef typename _MapT<MMAP>::ValIter Range;
405 typedef typename _MapT<MMAP>::PickValIter PickVal;
407 std::pair<Pos,Pos> valRange = multimap.equal_range (key);
409 return Range (PickVal (valRange.first), PickVal (valRange.second));
422 template<
typename VAL>
425 typedef std::vector<VAL> Sequence;
444 buffer_.push_back(*src);
454 for (IT copy{src}; copy; ++copy)
455 buffer_.push_back(*copy);
462 for ( ; pos!=end; ++pos)
463 buffer_.push_back(*pos);
470 for (IT pos{begin}; pos!=end; ++pos)
471 buffer_.push_back(*pos);
480 operator bool()
const 488 return buffer_.size();
495 typedef VAL* pointer;
496 typedef VAL& reference;
497 typedef VAL value_type;
503 return buffer_[pos_];
510 return &buffer_[pos_];
524 return pos_ < buffer_.size();
530 return not isValid();
541 return (s1.empty() and s2.empty())
542 or (s1.isValid() and s2.isValid()
543 and s1.pos_ == s2.pos_
544 and s1.buffer_ == s2.buffer_
551 return not (snap1 == snap2);
560 _throwIterExhausted();
577 inline ContentSnapshot<CON>
580 return ContentSnapshot<CON>{begin(con), end(con)};
587 inline ContentSnapshot<IT>
590 return ContentSnapshot<IT>{ii};
607 return OnceIter(begin(ili), end(ili));
IterSnapshot(IT &src)
take snapshot by discharging the given Lumiera Forward iterator
helper to access the parts of the pair values correctly...
Extension adapter for Lumiera Forward Iterators to dereference any pointer values automatically...
IterSnapshot(IT const &begin, IT const &end)
take snapshot from STL iterator
Helper template(s) for creating Lumiera Forward Iterators.
ContentSnapshot< CON > snapshot(CON const &con)
Take a snapshot of the given STL compliant container.
#define ENABLE_USE_IN_STD_RANGE_FOR_LOOPS(ITER)
use a given Lumiera Forward Iterator in standard "range for loops"
IterSnapshot(IT &pos, IT const &end)
take snapshot by consuming a STL iterator
Wrapped-Iter-Policy: picking the value part of a pair iterator (map or multimap). ...
Implementation namespace for support and library code.
_MapT< MAP >::DistinctKeys eachDistinctKey(MAP &map)
Wrapped-Iter-Policy: picking the key part of a pair iterator (map or multimap).
_MapT< MMAP >::ValIter eachValForKey(MMAP &multimap, KEY key)
_MapT< MAP >::KeyIter eachKey(MAP &map)
wrapper for an existing Iterator type to expose the address of each value yielded.
Wrapped-Iter-Policy: forwarding directly with typing retained unaltered.
IterSnapshot()
create empty snapshot
_MapT< MAP >::ValIter eachVal(MAP &map)
ContentSnapshot< IT > dischargeToSnapshot(IT &ii)
Take a snapshot of the given LumieraIterator, which is thereby consumed.
_SeqT< CON >::Range eachElm(CON &coll)
helper baseclass to simplify defining customised wrapped STL iterators
_SeqT< SEQ >::DistinctVals eachDistinct(SEQ &seq)
build a Lumiera Forward Iterator to suppress any repetitions in the given sequence.
_SeqT< CON >::Addrs eachAddress(CON &coll)
Accessing a STL element range through a Lumiera forward iterator, An instance of this iterator adapte...
materialised iterator contents.
Helper to filter repeated values from a wrapped iterator (both STL or Lumiera)
IterSnapshot(IT const &src)
build snapshot from a copy of the Lumiera Iterator