Lumiera  0.pre.03
»edit your freedom«
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 865 of file iter-explorer.hpp.

Public Types

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

Public Member Functions

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

Classes

struct  Buffer
 

Protected Types

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

Protected Member Functions

void pullGroup ()
 
SRC & srcIter () const
 

Protected Attributes

Buffer buff_
 
uint pos_ {0}
 

Member Function Documentation

◆ getGroupedElms()

auto getGroupedElms ( )
inline

Iterate over the Elements in the current group.

Returns
a Lumiera Forward Iterator with value type RES

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

◆ getRestElms()

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 918 of file iter-explorer.hpp.

◆ expandChildren()

void expandChildren ( )
inline

refresh state when other layers manipulate the source sequence.

Note
possibly pulls to re-establish the invariant

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

◆ pullGroup()

void pullGroup ( )
inlineprotected
Note
establishes the invariant: source has been consumed to fill a group

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

+ 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: