Library of Assembled Shared Sources
lass::python::IndexedRangeView< SelfType, ValueType, SizeType, AtMethod, SizeMethod > Class Template Reference

View that adapts index-based element access to a PyIteratorRange. More...

#include <pyiteratorrange.h>

Related Symbols

(Note that these are not member symbols.)

template<typename T, typename AtMethod, typename SizeMethod>
auto makeIndexedRangeView (const ShadoweePtr< T > &self, AtMethod atMethod, SizeMethod sizeMethod)
 Returns a IndexedRangeView iterating over (self->*atMethod)(index) for index in 0 to (self->*sizeMethod)() - 1
 
template<typename T, typename AtMethod, typename SizeMethod>
auto makeIndexedRangeViewFactory (AtMethod atMethod, SizeMethod sizeMethod)
 Returns callable that creates a IndexedRangeView iterating over (self->*atMethod)(index) for index in 0 to (self->*sizeMethod)() - 1
 

Detailed Description

template<typename SelfType, typename ValueType, typename SizeType, typename AtMethod, typename SizeMethod>
class lass::python::IndexedRangeView< SelfType, ValueType, SizeType, AtMethod, SizeMethod >

View that adapts index-based element access to a PyIteratorRange.

IndexedRangeView holds a ShadoweePtr to the container, and iterates ove the elements by index. It uses the supplied member functions atMethod and sizeMethod to access the elements and the size of the container.

It retrieves the size of the container by calling (self->*sizeMethod)() once when the iteration starts, and accesses the elements by calling (self->*atMethod)(index) for each index from 0 to size-1.

iter() produces a PyIteratorRange and sets self as its owner, keeping the container alive for the duration of the iteration.

Template Parameters
SelfTypeC++ container type
ValueTypeElement type returned by the container's iterators
SizeTypeArgument type of AtMethod and return type of SizeMethod
AtMethodMember function type of the element accessor; expected to accept a SizeType index and return a ValueType
SizeMethodMember function type of the size accessor; expected to return a SizeType

Definition at line 519 of file pyiteratorrange.h.


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