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

#include "lib/iter-explorer.hpp"

Description

template<class SRC, class RES, uint grp>
class lib::iter_explorer::Grouping< SRC, RES, grp >

Decorator for IterExplorer to group consecutive elements into fixed sized chunks. One group of elements is always prepared eagerly, and then the next one on iteration. The group is packaged into a std::array, returning a reference into the internal buffer. If there are leftover elements at the end of the source sequence, which are not sufficient to fill a full group, these can be retrieved through the special API getRestElms(), which returns an iterator.

Definition at line 892 of file iter-explorer.hpp.

Classes

struct  Buffer
 

Public Types

using value_type = Group
 
using reference = Group &
 
using pointer = Group *
 

Public Member Functions

 Grouping ()=default
 
 Grouping (SRC &&dataSrc)
 
auto getGroupedElms ()
 Iterate over the Elements in the current group.
 
auto getRestElms ()
 Retrieve the tail elements produced by the source, which did not suffice to fill a full group.
 
void expandChildren ()
 refresh state when other layers manipulate the source sequence.
 
bool checkPoint () const
 
reference yield () const
 
void iterNext ()
 

Protected Types

using Group = std::array< RES, grp >
 
using Iter = Group::iterator
 

Protected Member Functions

SRC & srcIter () const
 
void pullGroup ()
 

Protected Attributes

Buffer buff_
 
uint pos_ {0}
 

Constructor & Destructor Documentation

◆ Grouping() [1/2]

template<class SRC , class RES , uint grp>
Grouping ( )
default

◆ Grouping() [2/2]

template<class SRC , class RES , uint grp>
Grouping ( SRC &&  dataSrc)
inline

Definition at line 919 of file iter-explorer.hpp.

References Grouping< SRC, RES, grp >::pullGroup().

+ Here is the call graph for this function:

Member Typedef Documentation

◆ Group

template<class SRC , class RES , uint grp>
using Group = std::array<RES, grp>
protected

Definition at line 898 of file iter-explorer.hpp.

◆ Iter

template<class SRC , class RES , uint grp>
using Iter = Group::iterator
protected

Definition at line 899 of file iter-explorer.hpp.

◆ value_type

template<class SRC , class RES , uint grp>
using value_type = Group

Definition at line 912 of file iter-explorer.hpp.

◆ reference

template<class SRC , class RES , uint grp>
using reference = Group&

Definition at line 913 of file iter-explorer.hpp.

◆ pointer

template<class SRC , class RES , uint grp>
using pointer = Group*

Definition at line 914 of file iter-explorer.hpp.

Member Function Documentation

◆ getGroupedElms()

template<class SRC , class RES , uint grp>
auto getGroupedElms ( )
inline

Iterate over the Elements in the current group.

Returns
a Lumiera Forward Iterator with value type RES

Definition at line 931 of file iter-explorer.hpp.

References Grouping< SRC, RES, grp >::Buffer::begin(), Grouping< SRC, RES, grp >::buff_, Grouping< SRC, RES, grp >::Buffer::end(), and Grouping< SRC, RES, grp >::pos_.

Referenced by Grouping< SRC, RES, grp >::getRestElms().

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

◆ getRestElms()

template<class SRC , class RES , uint grp>
auto getRestElms ( )
inline

Retrieve the tail elements produced by the source, which did not suffice to fill a full group.

Remarks
getRest() is NIL during regular iteration, but possibly yields elements when checkPoint() = false;

Definition at line 945 of file iter-explorer.hpp.

References Grouping< SRC, RES, grp >::checkPoint(), and Grouping< SRC, RES, grp >::getGroupedElms().

+ Here is the call graph for this function:

◆ expandChildren()

template<class SRC , class RES , uint grp>
void expandChildren ( )
inline

refresh state when other layers manipulate the source sequence.

Note
possibly pulls to re-establish the invariant

Definition at line 954 of file iter-explorer.hpp.

References Grouping< SRC, RES, grp >::pullGroup().

+ Here is the call graph for this function:

◆ checkPoint()

template<class SRC , class RES , uint grp>
bool checkPoint ( ) const
inline

Definition at line 963 of file iter-explorer.hpp.

References Grouping< SRC, RES, grp >::pos_.

Referenced by Grouping< SRC, RES, grp >::getRestElms().

+ Here is the caller graph for this function:

◆ yield()

template<class SRC , class RES , uint grp>
reference yield ( ) const
inline

Definition at line 969 of file iter-explorer.hpp.

References Grouping< SRC, RES, grp >::buff_.

◆ iterNext()

template<class SRC , class RES , uint grp>
void iterNext ( )
inline

Definition at line 975 of file iter-explorer.hpp.

References Grouping< SRC, RES, grp >::pullGroup().

+ Here is the call graph for this function:

◆ srcIter()

template<class SRC , class RES , uint grp>
SRC & srcIter ( ) const
inlineprotected

Definition at line 983 of file iter-explorer.hpp.

Referenced by Grouping< SRC, RES, grp >::pullGroup().

+ Here is the caller graph for this function:

◆ pullGroup()

template<class SRC , class RES , uint grp>
void pullGroup ( )
inlineprotected
Note
establishes the invariant: source has been consumed to fill a group

Definition at line 991 of file iter-explorer.hpp.

References Grouping< SRC, RES, grp >::buff_, Grouping< SRC, RES, grp >::Buffer::group(), Grouping< SRC, RES, grp >::pos_, and Grouping< SRC, RES, grp >::srcIter().

Referenced by Grouping< SRC, RES, grp >::Grouping(), Grouping< SRC, RES, grp >::expandChildren(), and Grouping< SRC, RES, grp >::iterNext().

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

Member Data Documentation

◆ buff_

template<class SRC , class RES , uint grp>
Buffer buff_
protected

◆ pos_

template<class SRC , class RES , uint grp>
uint pos_ {0}
protected
+ Inheritance diagram for Grouping< SRC, RES, grp >:
+ Collaboration diagram for Grouping< SRC, RES, grp >:

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