Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
IterChainSearch< SRC > Class Template Reference

#include "lib/iter-chain-search.hpp"

Description

template<class SRC>
class lib::iter::IterChainSearch< SRC >

Iterator based linear search mechanism, with the ability to perform consecutive search with backtracking.

The IterChainSearch can be configured with a sequence of search goals (filter conditions), and will apply these in succession on the underlying iterator. It will search by linear search for the first hit of the first condition, and then continue to search from there matching on the second condition, and so on. After the first combination of matches is exhausted, the search will backtrack and try to evaluate the next combination, leading to a tree of on-demand search solutions.

Definition at line 149 of file iter-chain-search.hpp.

Public Member Functions

template<class SEQ >
 IterChainSearch (SEQ &&srcData)
 Build a chain-search mechanism based on the given source data sequence.
 
void iterNext ()
 
IterChainSearchoperator++ ()
 
template<typename FUN >
IterChainSearch && addStep (FUN &&configureSearchStep)
 configure additional chained search condition.
 
template<typename FUN >
disable_if< is_convertible< FUN, Value >, IterChainSearch && > search (FUN &&filterPredicate)
 attach additional search with the given filter predicate.
 
IterChainSearch && search (Value target)
 attach additional direct search for a given value.
 
IterChainSearch && clearFilter ()
 drop all search condition frames.
 

Private Types

using _Trait = _IterChainSetup< SRC >
 
using _Base = _Trait::Pipeline
 
using Value = _Base::value_type
 
using Filter = _Trait::Filter
 
using Step = _Trait::StepFunctor
 

Private Member Functions

bool needsExpansion () const
 

Private Attributes

std::vector< StepstepChain_
 Storage for a sequence of filter configuration functors.
 

Constructor & Destructor Documentation

◆ IterChainSearch()

template<class SRC >
template<class SEQ >
IterChainSearch ( SEQ &&  srcData)
inlineexplicit

Build a chain-search mechanism based on the given source data sequence.

Remarks
iterators will be copied or moved as appropriate, while from a STL compliant container just a pair of (begin(), end()) iterators is retrieved; the latter is also the reason why a rvalue reference to STL container is rejected, since the container needs to reside elsewhere; only the iterator is wrapped here.

Definition at line 178 of file iter-chain-search.hpp.

Member Typedef Documentation

◆ _Trait

template<class SRC >
using _Trait = _IterChainSetup<SRC>
private

Definition at line 152 of file iter-chain-search.hpp.

◆ _Base

template<class SRC >
using _Base = _Trait::Pipeline
private

Definition at line 153 of file iter-chain-search.hpp.

◆ Value

template<class SRC >
using Value = _Base::value_type
private

Definition at line 155 of file iter-chain-search.hpp.

◆ Filter

template<class SRC >
using Filter = _Trait::Filter
private

Definition at line 156 of file iter-chain-search.hpp.

◆ Step

template<class SRC >
using Step = _Trait::StepFunctor
private

Definition at line 157 of file iter-chain-search.hpp.

Member Function Documentation

◆ needsExpansion()

template<class SRC >
bool needsExpansion ( ) const
inlineprivate

Definition at line 164 of file iter-chain-search.hpp.

References IterChainSearch< SRC >::stepChain_.

Referenced by IterChainSearch< SRC >::iterNext().

+ Here is the caller graph for this function:

◆ iterNext()

template<class SRC >
void iterNext ( )
inline

Definition at line 190 of file iter-chain-search.hpp.

References IterChainSearch< SRC >::needsExpansion(), and IterChainSearch< SRC >::stepChain_.

Referenced by IterChainSearch< SRC >::addStep(), and IterChainSearch< SRC >::operator++().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator++()

template<class SRC >
IterChainSearch & operator++ ( )
inline

Definition at line 206 of file iter-chain-search.hpp.

References IterChainSearch< SRC >::iterNext().

+ Here is the call graph for this function:

◆ addStep()

template<class SRC >
template<typename FUN >
IterChainSearch && addStep ( FUN &&  configureSearchStep)
inline

configure additional chained search condition.

Parameters
amanipulation functor void(Filter&), which works on the current filter to possibly change its configuration.
Note
the given functor, lambda or function reference will be wrapped and adapted to conform to the required function signature. When using a generic lambda, the argument type Filter& is used for instantiation
Remarks
the additional chained search condition given here will be applied after matching all other conditions already in the filter chain. Each such condition is used to filter the underlying source iterator, i.e. pull it until finding an element to match the condition. Basically these conditions are not used in conjunction, but rather one after another. But since each such step in the chain is defined by a functor, which gets the previous filter configuration as argument, it is possible to build a step which extends or sharpens the preceding condition.

Definition at line 230 of file iter-chain-search.hpp.

References IterChainSearch< SRC >::iterNext(), and IterChainSearch< SRC >::stepChain_.

Referenced by IterChainSearch< SRC >::search().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ search() [1/2]

template<class SRC >
template<typename FUN >
disable_if< is_convertible< FUN, Value >, IterChainSearch && > search ( FUN &&  filterPredicate)
inline

attach additional search with the given filter predicate.

After successfully searching for all the conditions currently in the filter chain, the embedded iterator will finally be pulled until matching the given target value.

Remarks
adds a new layer on the stack of search conditions with a copy of the previously used iterator, and installs the given filter predicate therein.

Definition at line 256 of file iter-chain-search.hpp.

References IterChainSearch< SRC >::addStep().

Referenced by IterChainSearch< SRC >::search().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ search() [2/2]

template<class SRC >
IterChainSearch && search ( Value  target)
inline

attach additional direct search for a given value.

After successfully searching for all the conditions currently in the filter chain, the embedded iterator will finally be pulled until matching the given target value.

Definition at line 271 of file iter-chain-search.hpp.

References IterChainSearch< SRC >::search().

+ Here is the call graph for this function:

◆ clearFilter()

template<class SRC >
IterChainSearch && clearFilter ( )
inline

drop all search condition frames.

Remarks
the filter chain becomes empty, passing through the reset of the source sequence unaltered

Definition at line 283 of file iter-chain-search.hpp.

References IterChainSearch< SRC >::stepChain_.

Member Data Documentation

◆ stepChain_

template<class SRC >
std::vector<Step> stepChain_
private

Storage for a sequence of filter configuration functors.

Definition at line 160 of file iter-chain-search.hpp.

Referenced by IterChainSearch< SRC >::addStep(), IterChainSearch< SRC >::clearFilter(), IterChainSearch< SRC >::iterNext(), and IterChainSearch< SRC >::needsExpansion().

+ Inheritance diagram for IterChainSearch< SRC >:
+ Collaboration diagram for IterChainSearch< SRC >:

The documentation for this class was generated from the following file: