31 #ifndef LIB_ITER_ADAPTER_STL_H 32 #define LIB_ITER_ADAPTER_STL_H 52 using value_type =
typename IT::value_type;
53 using reference =
typename IT::reference;
54 using pointer =
typename IT::pointer;
60 void memorise() {
if (i_) prev_ = &(*i_); }
64 DistinctIter(IT
const& i) : i_(i),prev_() { memorise(); }
66 pointer operator->()
const {
return i_; }
67 reference operator*()
const {
return *i_; }
68 bool isValid()
const {
return i_; }
81 while (i_ && prev_ && *prev_ == *i_ );
96 template<
typename DEF>
99 typedef typename DEF::Iter Iter;
100 typedef typename DEF::reference reference;
101 typedef typename DEF::pointer pointer;
107 pointer operator->()
const {
return DEF::get(i_); }
108 reference operator*()
const {
return *(DEF::get(i_)); }
126 template<
typename IT>
130 using value_type =
typename IT::value_type;
131 using reference =
typename IT::reference;
132 using pointer =
typename IT::pointer;
134 static Iter
get (Iter& it) {
return & (*it); }
141 template<
typename IT>
145 using value_type =
typename IT::value_type::first_type;
146 using reference = value_type &;
147 using pointer = value_type *;
149 static pointer
get (Iter& it) {
return & (it->first); }
156 template<
typename IT>
160 using value_type =
typename IT::value_type::second_type;
161 using reference = value_type &;
162 using pointer = value_type *;
164 static pointer
get (Iter& it) {
return & (it->second); }
167 template<
typename IT>
171 using value_type =
const typename IT::value_type::second_type;
172 using reference =
const value_type &;
173 using pointer =
const value_type *;
175 static pointer
get (Iter& it) {
return & (it->second); }
188 typedef typename MAP::value_type::first_type Key;
189 typedef typename MAP::value_type::second_type Val;
190 typedef typename MAP::iterator Itr;
196 typedef typename MAP::value_type::first_type Key;
197 typedef typename MAP::value_type::second_type
const Val;
198 typedef typename MAP::const_iterator Itr;
202 template<
class IT,
typename SEL>
210 template<
class IT,
typename SEL>
222 typedef typename _MapTypeSelector<MAP>::Key KeyType;
223 typedef typename _MapTypeSelector<MAP>::Val ValType;
224 typedef typename _MapTypeSelector<MAP>::Itr EntryIter;
226 typedef typename EntryIter::reference DetectConst;
240 typedef IT EntryIter;
242 typedef typename EntryIter::value_type::first_type KeyType;
243 typedef typename EntryIter::value_type::second_type ValType;
245 typedef typename EntryIter::reference DetectConst;
260 typedef typename SEQ::iterator Iter;
269 typedef typename SEQ::const_iterator Iter;
287 typedef typename _SeqT<CON>::Range Range;
288 return Range (coll.begin(), coll.end());
296 inline typename _SeqT<CON>::Addrs
299 typedef typename _SeqT<CON>::Addrs Addresses;
300 return Addresses (
eachElm (coll));
308 inline typename _MapT<MAP>::KeyIter
311 typedef typename _MapT<MAP>::KeyIter Range;
312 typedef typename _MapT<MAP>::PickKeyIter PickKey;
314 return Range (PickKey (map.begin()), PickKey (map.end()));
322 inline typename _MapIterT<IT>::KeyIter
325 typedef typename _MapIterT<IT>::KeyIter Range;
326 typedef typename _MapIterT<IT>::PickKeyIter PickKey;
328 return Range (PickKey (begin), PickKey (end));
336 inline typename _MapT<MAP>::ValIter
339 typedef typename _MapT<MAP>::ValIter Range;
340 typedef typename _MapT<MAP>::PickValIter PickVal;
342 return Range (PickVal (map.begin()), PickVal (map.end()));
350 inline typename _MapIterT<IT>::ValIter
353 typedef typename _MapIterT<IT>::ValIter Range;
354 typedef typename _MapIterT<IT>::PickValIter PickVal;
356 return Range (PickVal (begin), PickVal (end));
364 inline typename _SeqT<SEQ>::DistinctVals
367 typedef typename _SeqT<SEQ>::Range Range;
368 typedef typename _SeqT<SEQ>::DistinctVals DistinctValues;
370 return DistinctValues (Range (seq.begin(), seq.end()));
379 inline typename _MapT<MAP>::DistinctKeys
382 return typename _MapT<MAP>::DistinctKeys (
eachKey (map));
390 template<
class MMAP,
typename KEY>
391 inline typename _MapT<MMAP>::ValIter
394 typedef typename _MapT<MMAP>::EntryIter Pos;
395 typedef typename _MapT<MMAP>::ValIter Range;
396 typedef typename _MapT<MMAP>::PickValIter PickVal;
398 std::pair<Pos,Pos> valRange = multimap.equal_range (key);
400 return Range (PickVal (valRange.first), PickVal (valRange.second));
413 template<
typename VAL>
416 typedef std::vector<VAL> Sequence;
435 buffer_.emplace_back (*src);
445 for (IT copy{src}; copy; ++copy)
446 buffer_.emplace_back (*copy);
453 for ( ; pos!=end; ++pos)
454 buffer_.emplace_back (*pos);
461 for (IT pos{begin}; pos!=end; ++pos)
462 buffer_.emplace_back (*pos);
471 operator bool()
const 479 return buffer_.size();
486 typedef VAL* pointer;
487 typedef VAL& reference;
488 typedef VAL value_type;
494 return buffer_[pos_];
501 return &buffer_[pos_];
515 return pos_ < buffer_.size();
521 return not isValid();
532 return (s1.empty() and s2.empty())
533 or (s1.isValid() and s2.isValid()
534 and s1.pos_ == s2.pos_
535 and s1.buffer_ == s2.buffer_
542 return not (snap1 == snap2);
551 _throwIterExhausted();
568 inline ContentSnapshot<CON>
571 return ContentSnapshot<CON>{begin(con), end(con)};
578 inline ContentSnapshot<IT>
581 return ContentSnapshot<IT>{ii};
598 return OnceIter(begin(ili), end(ili));
helper to access the parts of the pair values correctly...
IterSnapshot(IT &&pos, IT const &end)
take snapshot by consuming a STL iterator
Extension adapter for Lumiera Forward Iterators to dereference any pointer values automatically...
IterSnapshot(IT &&src)
take snapshot by discharging the given Lumiera Forward iterator
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"
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