67 #ifndef LIB_ITERTOOLS_H 68 #define LIB_ITERTOOLS_H 110 : source_{forward<IT>(orig)}
137 return bool(source_);
140 typedef typename IT::pointer pointer;
141 typedef typename IT::reference reference;
142 typedef typename IT::value_type value_type;
164 return core_.evaluate()
165 || unConst(
this)->iterate();
171 if (!core_.pipe())
return false;
174 while (core_.pipe() && !core_.evaluate());
176 return bool{core_.pipe()};
183 _throwIterExhausted();
189 typedef typename CORE::pointer pointer;
190 typedef typename CORE::reference reference;
191 typedef typename CORE::value_type value_type;
195 : core_{std::move(
setup)}
201 operator bool()
const 214 return *core_.pipe();
221 return & *core_.pipe();
241 return not isValid();
251 return (!it1 && !it2 )
252 || ( it1 && it2 && (*it1) == (*it2) )
260 return not (ito1 == ito2);
283 using Val = iter::Yield<IT>;
286 function<bool(Val)> predicate_;
296 mutable bool cached_;
302 return (cached_ && isOK_)
304 &&(isOK_ = predicate_(*Raw::pipe())));
315 template<
typename PRED>
317 :
Raw{forward<IT>(source)}
318 , predicate_(prediDef)
323 template<
typename PRED>
326 , predicate_(prediDef)
344 static bool acceptAll(
typename _Filter::Val) {
return true; }
351 template<
typename PRED>
352 FilterIter (IT
const& src, PRED filterPredicate)
353 : _Impl{_Filter(src, filterPredicate)}
356 template<
typename PRED>
358 : _Impl{_Filter(forward<IT>(src), filterPredicate)}
370 template<
class IT,
typename PRED>
377 template<
class IT,
typename PRED>
381 using SrcIT =
typename std::remove_reference<IT>::type;
414 using Val =
typename _Filter::Val;
419 this->core_.cached_ =
false;
426 template<
typename PRED>
430 template<
typename PRED>
447 return this->core_.source_;
451 template<
typename COND>
453 andFilter (COND conjunctiveClause)
455 function<bool(Val)>&
filter = this->core_.predicate_;
457 filter = [=](Val val)
460 and conjunctiveClause(val);
466 template<
typename COND>
468 andNotFilter (COND conjunctiveClause)
470 function<bool(Val)>&
filter = this->core_.predicate_;
472 filter = [=](Val val)
475 and not conjunctiveClause(val);
481 template<
typename COND>
483 orFilter (COND disjunctiveClause)
485 function<bool(Val)>&
filter = this->core_.predicate_;
487 filter = [=](Val val)
490 or disjunctiveClause(val);
496 template<
typename COND>
498 orNotFilter (COND disjunctiveClause)
500 function<bool(Val)>&
filter = this->core_.predicate_;
502 filter = [=](Val val)
505 or not disjunctiveClause(val);
512 template<
typename COND>
514 setNewFilter (COND entirelyDifferentPredicate)
516 this->core_.predicate_ = entirelyDifferentPredicate;
524 function<bool(Val)>&
filter = this->core_.predicate_;
526 filter = [=](Val val)
542 template<
typename VAL>
551 operator() (VAL
const& elm)
562 typedef bool result_type;
578 template<
typename VAL>
589 : theValue_{forward<VAL> (something)}
607 return theValue_.isValid();
610 typedef std::remove_reference_t<VAL> * pointer;
611 typedef std::remove_reference_t<VAL> & reference;
612 typedef std::remove_reference_t<VAL> value_type;
627 :
public IterTool<SingleValCore<VAL>>
678 template<
class IT,
class VAL>
681 using InType = iter::Yield<IT>;
684 function<VAL(InType)> trafo_;
693 treated_ = trafo_(*source_);
707 template<
typename FUN>
710 , source_(forward<IT> (orig))
715 template<
typename FUN>
739 return bool(source_);
742 using pointer =
typename ValueTypeBinding<VAL>::pointer;
743 using reference =
typename ValueTypeBinding<VAL>::reference;
744 using value_type =
typename ValueTypeBinding<VAL>::value_type;
753 template<
class IT,
class VAL>
755 :
public IterTool<TransformingCore<IT,VAL>>
765 template<
typename FUN>
769 template<
typename FUN>
786 template<
class IT,
typename FUN>
794 template<
class IT,
typename FUN>
798 using SrcIT =
typename std::remove_reference<IT>::type;
808 template<
class IT,
class CON>
810 append_all (IT
iter, CON& container)
812 for ( ; iter; ++iter )
813 container.push_back (*iter);
818 inline typename IT::value_type
821 using Val =
typename IT::value_type;
836 "of an exhausted or empty iterator" 837 ,lumiera::error::LUMIERA_ERROR_ITER_EXHAUST);
848 using Val =
typename meta::ValueTypeBinding<IT>::value_type;
856 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