![]() |
Lumiera 0.pre.04
»edit your freedom«
|
#include "lib/iter-explorer.hpp"
Decorator for IterExplorer to group consecutive elements controlled by some grouping value GRP and compute an aggregate value AGG for each such group as iterator yield. The first group is consumed eagerly, each further group on iteration; thus when the aggregate for the last group appears as result, the source iterator has already been exhausted. The aggregate is default-initialised at start of each group and then the computation functor FAGG is invoked for each consecutive element marked with the same grouping value — and this grouping value itself is obtained by invoking the functor FGRP on each source value. All computation are performed on-the-fly. No capturing or reordering of the source elements takes place, rather groups are formed based on the changes of the grouping value over the source iterator's result sequence.
| AGG | data type to collect the aggregate; must be default constructible and assignable |
| GRP | value type to indicate a group |
groupFun is adapted, the aggFun is not adapted to the source iterator, but expected always to take the value type of the preceding iterator, i.e. *srcIter. This limitation was deemed acceptable (adapting a function with several arguments would require quite some nasty technicalities). The first argument of this aggFun refers to the accumulator by value, and thereby also implicitly defines the aggregate result type. Definition at line 1025 of file iter-explorer.hpp.
Public Types | |
| using | value_type = meta::RefTraits< AGG >::Value |
| using | reference = meta::RefTraits< AGG >::Reference |
| using | pointer = meta::RefTraits< AGG >::Pointer |
Public Member Functions | |
| GroupAggregator ()=default | |
| template<class FGRP , class FAGG > | |
| GroupAggregator (SRC &&dataSrc, FGRP &&groupFun, FAGG &&aggFun) | |
| bool | checkPoint () const |
| reference | yield () const |
| void | iterNext () |
Protected Types | |
| using | SrcValue = meta::ValueTypeBinding< SRC >::value_type |
| using | Grouping = function< GRP(SRC &)> |
| using | Aggregator = function< void(AGG &, SrcValue &)> |
Protected Member Functions | |
| SRC & | srcIter () const |
| void | pullGroup () |
Protected Attributes | |
| std::optional< AGG > | agg_ {} |
| Grouping | grouping_ |
| Aggregator | aggregate_ |
|
default |
|
inline |
Definition at line 1049 of file iter-explorer.hpp.
References GroupAggregator< SRC, AGG, GRP >::pullGroup().
Here is the call graph for this function:
|
protected |
Definition at line 1031 of file iter-explorer.hpp.
|
protected |
Definition at line 1032 of file iter-explorer.hpp.
|
protected |
Definition at line 1033 of file iter-explorer.hpp.
| using value_type = meta::RefTraits<AGG>::Value |
Definition at line 1041 of file iter-explorer.hpp.
| using reference = meta::RefTraits<AGG>::Reference |
Definition at line 1042 of file iter-explorer.hpp.
| using pointer = meta::RefTraits<AGG>::Pointer |
Definition at line 1043 of file iter-explorer.hpp.
|
inline |
Definition at line 1060 of file iter-explorer.hpp.
References GroupAggregator< SRC, AGG, GRP >::agg_.
|
inline |
Definition at line 1066 of file iter-explorer.hpp.
|
inline |
Definition at line 1072 of file iter-explorer.hpp.
References GroupAggregator< SRC, AGG, GRP >::agg_, GroupAggregator< SRC, AGG, GRP >::pullGroup(), and GroupAggregator< SRC, AGG, GRP >::srcIter().
Here is the call graph for this function:
|
inlineprotected |
Definition at line 1083 of file iter-explorer.hpp.
Referenced by GroupAggregator< SRC, AGG, GRP >::iterNext(), and GroupAggregator< SRC, AGG, GRP >::pullGroup().
Here is the caller graph for this function:
|
inlineprotected |
Definition at line 1091 of file iter-explorer.hpp.
References GroupAggregator< SRC, AGG, GRP >::agg_, GroupAggregator< SRC, AGG, GRP >::aggregate_, GroupAggregator< SRC, AGG, GRP >::grouping_, and GroupAggregator< SRC, AGG, GRP >::srcIter().
Referenced by GroupAggregator< SRC, AGG, GRP >::GroupAggregator(), and GroupAggregator< SRC, AGG, GRP >::iterNext().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
Definition at line 1035 of file iter-explorer.hpp.
Referenced by GroupAggregator< SRC, AGG, GRP >::checkPoint(), GroupAggregator< SRC, AGG, GRP >::iterNext(), and GroupAggregator< SRC, AGG, GRP >::pullGroup().
|
protected |
Definition at line 1037 of file iter-explorer.hpp.
Referenced by GroupAggregator< SRC, AGG, GRP >::pullGroup().
|
protected |
Definition at line 1038 of file iter-explorer.hpp.
Referenced by GroupAggregator< SRC, AGG, GRP >::pullGroup().
Inheritance diagram for GroupAggregator< SRC, AGG, GRP >:
Collaboration diagram for GroupAggregator< SRC, AGG, GRP >: