WireCellToolkit
Wire Cell Simulation, Signal Process and Reconstruction Toolki for Liquid Argon Detectors
WireCell::GeneratorIter< Callable, Value > Struct Template Reference

#include <GeneratorIter.h>

Inheritance diagram for WireCell::GeneratorIter< Callable, Value >:
Collaboration diagram for WireCell::GeneratorIter< Callable, Value >:

Public Member Functions

 GeneratorIter (const Callable &func)
 
void advance ()
 
Value operator* () const
 
GeneratorIteroperator++ ()
 
GeneratorIter operator++ (int)
 
bool operator== (const GeneratorIter &rhs) const
 
bool operator!= (const GeneratorIter &rhs) const
 
 operator bool () const
 

Public Attributes

size_t count
 
Callable func
 
Value last_val
 

Detailed Description

template<typename Callable, typename Value>
struct WireCell::GeneratorIter< Callable, Value >

A generator iterator using a Callable.

Requirements on Callable

  • returns Value.
  • evaluates as false when it is not exhausted, true otherwise.
  • copy-by-value, copies are independent.
  • instances must be testable for equality.

Inspired by: http://stackoverflow.com/questions/27604201/implement-lazy-generator-as-forward-iterator-in-c

Definition at line 31 of file GeneratorIter.h.

Constructor & Destructor Documentation

◆ GeneratorIter()

template<typename Callable , typename Value >
WireCell::GeneratorIter< Callable, Value >::GeneratorIter ( const Callable &  func)
inline

Definition at line 37 of file GeneratorIter.h.

Here is the call graph for this function:

Member Function Documentation

◆ advance()

template<typename Callable , typename Value >
void WireCell::GeneratorIter< Callable, Value >::advance ( )
inline

Definition at line 42 of file GeneratorIter.h.

Here is the caller graph for this function:

◆ operator bool()

template<typename Callable , typename Value >
WireCell::GeneratorIter< Callable, Value >::operator bool ( ) const
inline

Definition at line 66 of file GeneratorIter.h.

◆ operator!=()

template<typename Callable , typename Value >
bool WireCell::GeneratorIter< Callable, Value >::operator!= ( const GeneratorIter< Callable, Value > &  rhs) const
inline

Definition at line 62 of file GeneratorIter.h.

◆ operator*()

template<typename Callable , typename Value >
Value WireCell::GeneratorIter< Callable, Value >::operator* ( ) const
inline

Definition at line 47 of file GeneratorIter.h.

◆ operator++() [1/2]

template<typename Callable , typename Value >
GeneratorIter& WireCell::GeneratorIter< Callable, Value >::operator++ ( )
inline

Definition at line 50 of file GeneratorIter.h.

Here is the call graph for this function:

◆ operator++() [2/2]

template<typename Callable , typename Value >
GeneratorIter WireCell::GeneratorIter< Callable, Value >::operator++ ( int  )
inline

Definition at line 54 of file GeneratorIter.h.

Here is the call graph for this function:

◆ operator==()

template<typename Callable , typename Value >
bool WireCell::GeneratorIter< Callable, Value >::operator== ( const GeneratorIter< Callable, Value > &  rhs) const
inline

Definition at line 59 of file GeneratorIter.h.

Member Data Documentation

◆ count

template<typename Callable , typename Value >
size_t WireCell::GeneratorIter< Callable, Value >::count

Definition at line 70 of file GeneratorIter.h.

◆ func

template<typename Callable , typename Value >
Callable WireCell::GeneratorIter< Callable, Value >::func

Definition at line 71 of file GeneratorIter.h.

◆ last_val

template<typename Callable , typename Value >
Value WireCell::GeneratorIter< Callable, Value >::last_val

Definition at line 72 of file GeneratorIter.h.


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