Lumiera  0.pre.03
»edityourfreedom«
Expander< SRC, FUN > Class Template Reference

#include "lib/iter-tree-explorer.hpp"

Description

template<class SRC, class FUN>
class lib::iter_explorer::Expander< SRC, FUN >

Decorator for TreeExplorer adding the ability to "expand children". The expandChildren() operation is the key element of a depth-first evaluation: it consumes one element and performs a preconfigured expansion functor on that element to yield its "children". These are given in the form of another iterator, which needs to be compatible to the source iterator ("compatibility" boils down to both iterators yielding a compatible value type). Now, this sequence of children effectively replaces the expanded source element in the overall resulting sequence; which means, the nested sequence was flattened into the results. Since this expand() operation can again be invoked on the results, the implementation of such an evaluation requires a stack datastructure, so the nested iterator from each expand() invocation can be pushed to become the new active source for iteration. Thus the primary purpose of this Expander (decorator) is to integrate those "nested child iterators" seamlessly into the overall iteration process; once a child iterator is exhausted, it will be popped and iteration continues with the previous child iterator or finally with the source iterator wrapped by this decorator.

Remarks
since we allow a lot of leeway regarding the actual form and definition of the expansion functor, there is a lot of minute technical details, mostly confined within the _BoundFunctor traits.
Template Parameters
SRCthe wrapped source iterator, typically a TreeExplorer or nested decorator.
FUNthe concrete type of the functor passed. Will be dissected to find the signature

Definition at line 591 of file iter-tree-explorer.hpp.

Public Member Functions

 Expander ()=default
 
 Expander (SRC &&parentExplorer, FUN &&expandFunctor)
 
bool checkPoint () const
 
size_t depth () const
 diagnostics: current level of nested child expansion More...
 
void expandChildren ()
 core operation: expand current head element More...
 
void iterNext ()
 
SRC::reference yield () const
 

Private Types

using _Traits = _BoundFunctor< FUN, SRC >
 
using ExpandFunctor = typename _Traits::Functor
 
using ResIter = typename _DecoratorTraits< typename _Traits::Res >::SrcIter
 

Private Member Functions

void dropExhaustedChildren ()
 
bool hasChildren () const
 
void incrementCurrent ()
 
bool invariant () const
 

Private Attributes

ExpandFunctor expandChildren_
 
IterStack< ResIterexpansions_
 

Member Typedef Documentation

◆ _Traits

using _Traits = _BoundFunctor<FUN,SRC>
private

Definition at line 595 of file iter-tree-explorer.hpp.

◆ ExpandFunctor

using ExpandFunctor = typename _Traits::Functor
private

Definition at line 596 of file iter-tree-explorer.hpp.

◆ ResIter

using ResIter = typename _DecoratorTraits<typename _Traits::Res>::SrcIter
private

Definition at line 598 of file iter-tree-explorer.hpp.

Constructor & Destructor Documentation

◆ Expander() [1/2]

Expander ( )
default

◆ Expander() [2/2]

Expander ( SRC &&  parentExplorer,
FUN &&  expandFunctor 
)
inline

Definition at line 609 of file iter-tree-explorer.hpp.

Member Function Documentation

◆ expandChildren()

void expandChildren ( )
inline

core operation: expand current head element

Definition at line 618 of file iter-tree-explorer.hpp.

References ENSURE(), util::isnil(), and IterStack< TY >::push().

+ Here is the call graph for this function:

◆ depth()

size_t depth ( ) const
inline

diagnostics: current level of nested child expansion

Definition at line 635 of file iter-tree-explorer.hpp.

References IterStack< TY >::size().

+ Here is the call graph for this function:

◆ checkPoint()

bool checkPoint ( ) const
inline

Definition at line 644 of file iter-tree-explorer.hpp.

References ENSURE(), and util::isValid().

+ Here is the call graph for this function:

◆ yield()

SRC::reference yield ( ) const
inline

Definition at line 653 of file iter-tree-explorer.hpp.

◆ iterNext()

void iterNext ( )
inline

Definition at line 660 of file iter-tree-explorer.hpp.

References ENSURE().

+ Here is the call graph for this function:

◆ invariant()

bool invariant ( ) const
inlineprivate

Definition at line 669 of file iter-tree-explorer.hpp.

◆ hasChildren()

bool hasChildren ( ) const
inlineprivate

Definition at line 676 of file iter-tree-explorer.hpp.

◆ incrementCurrent()

void incrementCurrent ( )
inlineprivate

Definition at line 682 of file iter-tree-explorer.hpp.

◆ dropExhaustedChildren()

void dropExhaustedChildren ( )
inlineprivate

Definition at line 691 of file iter-tree-explorer.hpp.

Member Data Documentation

◆ expandChildren_

ExpandFunctor expandChildren_
private

Definition at line 600 of file iter-tree-explorer.hpp.

◆ expansions_

IterStack<ResIter> expansions_
private

Definition at line 603 of file iter-tree-explorer.hpp.

+ Inheritance diagram for Expander< SRC, FUN >:
+ Collaboration diagram for Expander< SRC, FUN >:

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