76 #ifndef LIB_ITERTOOLS_H 77 #define LIB_ITERTOOLS_H 119 : source_{forward<IT>(orig)}
146 return bool(source_);
149 typedef typename IT::pointer pointer;
150 typedef typename IT::reference reference;
151 typedef typename IT::value_type value_type;
173 return core_.evaluate()
174 || unConst(
this)->iterate();
180 if (!core_.pipe())
return false;
183 while (core_.pipe() && !core_.evaluate());
185 return bool{core_.pipe()};
192 _throwIterExhausted();
198 typedef typename CORE::pointer pointer;
199 typedef typename CORE::reference reference;
200 typedef typename CORE::value_type value_type;
204 : core_{std::move(
setup)}
210 operator bool()
const 223 return *core_.pipe();
230 return & *core_.pipe();
250 return not isValid();
260 return (!it1 && !it2 )
261 || ( it1 && it2 && (*it1) == (*it2) )
269 return not (ito1 == ito2);
292 using Val =
typename IT::reference;
295 function<bool(Val)> predicate_;
305 mutable bool cached_;
311 return (cached_ && isOK_)
313 &&(isOK_ = predicate_(*Raw::pipe())));
324 template<
typename PRED>
326 :
Raw{forward<IT>(source)}
327 , predicate_(prediDef)
332 template<
typename PRED>
335 , predicate_(prediDef)
353 static bool acceptAll(
typename _Filter::Val) {
return true; }
360 template<
typename PRED>
361 FilterIter (IT
const& src, PRED filterPredicate)
362 : _Impl{_Filter(src, filterPredicate)}
365 template<
typename PRED>
367 : _Impl{_Filter(forward<IT>(src), filterPredicate)}
379 template<
class IT,
typename PRED>
386 template<
class IT,
typename PRED>
390 using SrcIT =
typename std::remove_reference<IT>::type;
423 using Val =
typename _Filter::Val;
428 this->core_.cached_ =
false;
435 template<
typename PRED>
439 template<
typename PRED>
456 return this->core_.source_;
460 template<
typename COND>
462 andFilter (COND conjunctiveClause)
464 function<bool(Val)>&
filter = this->core_.predicate_;
466 filter = [=](Val val)
469 and conjunctiveClause(val);
475 template<
typename COND>
477 andNotFilter (COND conjunctiveClause)
479 function<bool(Val)>&
filter = this->core_.predicate_;
481 filter = [=](Val val)
484 and not conjunctiveClause(val);
490 template<
typename COND>
492 orFilter (COND disjunctiveClause)
494 function<bool(Val)>&
filter = this->core_.predicate_;
496 filter = [=](Val val)
499 or disjunctiveClause(val);
505 template<
typename COND>
507 orNotFilter (COND disjunctiveClause)
509 function<bool(Val)>&
filter = this->core_.predicate_;
511 filter = [=](Val val)
514 or not disjunctiveClause(val);
521 template<
typename COND>
523 setNewFilter (COND entirelyDifferentPredicate)
525 this->core_.predicate_ = entirelyDifferentPredicate;
533 function<bool(Val)>&
filter = this->core_.predicate_;
535 filter = [=](Val val)
551 template<
typename VAL>
560 operator() (VAL
const& elm)
571 typedef bool result_type;
587 template<
typename VAL>
598 : theValue_{forward<VAL> (something)}
616 return theValue_.isValid();
619 typedef std::remove_reference_t<VAL> * pointer;
620 typedef std::remove_reference_t<VAL> & reference;
621 typedef std::remove_reference_t<VAL> value_type;
636 :
public IterTool<SingleValCore<VAL>>
687 template<
class IT,
class VAL>
690 typedef typename IT::reference InType;
693 function<VAL(InType)> trafo_;
702 treated_ = trafo_(*source_);
716 template<
typename FUN>
719 , source_(forward<IT> (orig))
724 template<
typename FUN>
748 return bool(source_);
751 using pointer =
typename ValueTypeBinding<VAL>::pointer;
752 using reference =
typename ValueTypeBinding<VAL>::reference;
753 using value_type =
typename ValueTypeBinding<VAL>::value_type;
762 template<
class IT,
class VAL>
764 :
public IterTool<TransformingCore<IT,VAL>>
774 template<
typename FUN>
778 template<
typename FUN>
795 template<
class IT,
typename FUN>
803 template<
class IT,
typename FUN>
807 using SrcIT =
typename std::remove_reference<IT>::type;
817 template<
class IT,
class CON>
819 append_all (IT
iter, CON& container)
821 for ( ; iter; ++iter )
822 container.push_back (*iter);
827 inline typename IT::value_type
830 using Val =
typename IT::value_type;
845 "of an exhausted or empty iterator" 846 ,lumiera::error::LUMIERA_ERROR_ITER_EXHAUST);
857 using Val =
typename meta::ValueTypeBinding<IT>::value_type;
865 using Val =
typename meta::ValueTypeBinding<IT>::value_type;
Iterator tool filtering pulled data according to a predicate.
bool currVal_isOK() const
<
SingleValCore()
passive and empty
A neutral identity-function core, also serving as point-of reference how any core is intended to work...
bool filter(Placement< DummyMO > const &candidate)
a filter predicate to pick some objects from a resultset.
Implementation of a singleton value holder, which discards the contained value once "iterated"...
Helper template(s) for creating Lumiera Forward Iterators.
Type re-binding helper template for custom containers and adapters.
bool operator==(PtrDerefIter< I1 > const &il, PtrDerefIter< I2 > const &ir)
Supporting equality comparisons...
Additional capabilities for FilterIter, allowing to extend the filter condition underway.
#define ENABLE_USE_IN_STD_RANGE_FOR_LOOPS(ITER)
use a given Lumiera Forward Iterator in standard "range for loops"
Implementation namespace for support and library code.
Derived specific exceptions within Lumiera's exception hierarchy.
Metaprogramming tools for transforming functor types.
auto nilIterator()
not-anything-at-all iterator
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Helper: predicate returning true whenever the argument value changes during a sequence of invocations...
auto singleValIterator(VAL &&something)
Build a SingleValIter: convenience free function shortcut, to pick up just any value and wrap it as L...
Helpers for type detection, type rewriting and metaprogramming.
Implementation of the filter logic.
auto setup(FUN &&workFun)
Helper: setup a Worker-Pool configuration for the test.
Pseudo-Iterator to yield just a single value.
auto filterIterator(IT const &src, PRED filterPredicate)
Build a FilterIter: convenience free function shortcut, picking up the involved types automatically...
auto transformIterator(IT const &src, FUN processingFunc)
Build a TransformIter: convenience free function shortcut, picking up the involved types automaticall...
Library implementation: smart-pointer variations, wrappers and managing holders.
auto filterRepetitions(IT const &source)
filters away repeated values emitted by source iterator