67#ifndef LIB_ITERTOOLS_H
68#define LIB_ITERTOOLS_H
164 return core_.evaluate()
165 or unConst(
this)->iterate();
171 if (not
core_.pipe())
return false;
174 while (
core_.pipe() and not
core_.evaluate());
176 return bool{
core_.pipe()};
183 _throwIterExhausted();
201 operator bool()
const
214 return *
core_.pipe();
221 return & *
core_.pipe();
251 return (!it1 and !it2 )
252 or ( it1 and it2 and (*it1) == (*it2) )
260 return not (ito1 == ito2);
283 using Val = iter::Yield<IT>;
315 template<
typename PRED>
317 :
Raw{forward<IT>(source)}
323 template<
typename PRED>
351 template<
typename PRED>
356 template<
typename PRED>
370 template<
class IT,
typename PRED>
377 template<
class IT,
typename PRED>
381 using SrcIT = std::remove_reference<IT>::type;
419 this->
core_.cached_ =
false;
426 template<
typename PRED>
428 :
FilterIter<IT>{forward<IT>(src), initialFilterPredicate}
430 template<
typename PRED>
447 return this->
core_.source_;
451 template<
typename COND>
455 function<bool(
Val)>& filter = this->
core_.predicate_;
457 filter = [=](
Val val)
460 and conjunctiveClause(val);
466 template<
typename COND>
470 function<bool(
Val)>& filter = this->
core_.predicate_;
472 filter = [=](
Val val)
475 and not conjunctiveClause(val);
481 template<
typename COND>
485 function<bool(
Val)>& filter = this->
core_.predicate_;
487 filter = [=](
Val val)
490 or disjunctiveClause(val);
496 template<
typename COND>
500 function<bool(
Val)>& filter = this->
core_.predicate_;
502 filter = [=](
Val val)
505 or not disjunctiveClause(val);
512 template<
typename COND>
516 this->
core_.predicate_ = entirelyDifferentPredicate;
524 function<bool(
Val)>& filter = this->
core_.predicate_;
526 filter = [=](
Val val)
528 return not filter(val);
542 template<
typename VAL>
578 template<
typename VAL>
610 using pointer = std::remove_reference_t<VAL> *;
627 :
public IterTool<SingleValCore<VAL>>
678 template<
class IT,
class VAL>
707 template<
typename FUN>
715 template<
typename FUN>
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 = std::remove_reference<IT>::type;
808 template<
class IT,
class CON>
813 container.push_back (*
iter);
818 inline IT::value_type
821 using Val = IT::value_type;
836 "of an exhausted or empty iterator"
837 ,lumiera::error::LUMIERA_ERROR_ITER_EXHAUST);
Additional capabilities for FilterIter, allowing to extend the filter condition underway.
IT & underlying()
access the unfiltered source iterator in current state
ExtensibleFilterIter & andFilter(COND conjunctiveClause)
ExtensibleFilterIter & flipFilter()
ExtensibleFilterIter(IT &&src, PRED initialFilterPredicate)
ExtensibleFilterIter & setNewFilter(COND entirelyDifferentPredicate)
ExtensibleFilterIter(IT const &src, PRED initialFilterPredicate)
ExtensibleFilterIter & orFilter(COND disjunctiveClause)
ExtensibleFilterIter & andNotFilter(COND conjunctiveClause)
ExtensibleFilterIter(IT &&src)
ExtensibleFilterIter & orNotFilter(COND disjunctiveClause)
Iterator tool filtering pulled data according to a predicate.
static bool acceptAll(_Filter::Val)
IterTool< _Filter > _Impl
FilterIter(IT const &src, PRED filterPredicate)
FilterIter(IT &&src, PRED filterPredicate)
Implementation of a singleton value holder, which discards the contained value once "iterated".
SingleValCore(VAL &&something)
wrapper::ItemWrapper< VAL > Item
std::remove_reference_t< VAL > * pointer
SingleValCore()
passive and empty
std::remove_reference_t< VAL > value_type
Item const & pipe() const
std::remove_reference_t< VAL > & reference
Pseudo-Iterator to yield just a single value.
SingleValCore< VAL > _ValHolder
IterTool< _ValHolder > _IteratorImpl
SingleValIter(VAL &&something)
Helper: predicate returning true whenever the argument value changes during a sequence of invocations...
bool operator()(VAL const &elm)
Metaprogramming tools for detecting and transforming function types.
Adapter to store and hold an element of arbitrary type in local storage.
Helper template(s) for creating Lumiera Forward Iterators.
#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.
auto filterRepetitions(IT const &source)
filters away repeated values emitted by source iterator
bool operator==(PtrDerefIter< I1 > const &il, PtrDerefIter< I2 > const &ir)
Supporting equality comparisons...
void append_all(IT iter, CON &container)
auto nilIterator()
not-anything-at-all iterator
IT::value_type pull_last(IT iter)
auto transformIterator(IT const &src, FUN processingFunc)
Build a TransformIter: convenience free function shortcut, picking up the involved types automaticall...
bool operator!=(PtrDerefIter< I1 > const &il, PtrDerefIter< I2 > const &ir)
auto filterIterator(IT const &src, PRED filterPredicate)
Build a FilterIter: convenience free function shortcut, picking up the involved types automatically.
auto singleValIterator(VAL &&something)
Build a SingleValIter: convenience free function shortcut, to pick up just any value and wrap it as L...
LumieraError< LERR_(STATE)> State
OBJ * unConst(const OBJ *)
shortcut to save some typing when having to define const and non-const variants of member functions
Implementation of the filter logic.
bool currVal_isOK() const
<
FilterCore(IT const &source, PRED prediDef)
FilterCore(IT &&source, PRED prediDef)
function< bool(Val)> predicate_
A neutral identity-function core, also serving as point-of reference how any core is intended to work...
IT::value_type value_type
IdentityCore(IT const &orig)
Helpers for type detection, type rewriting and metaprogramming.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Type re-binding helper template for custom containers and adapters.