Library of Assembled Shared Sources
|
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 | |
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.
SelfType | C++ container type |
ValueType | Element type returned by the container's iterators |
SizeType | Argument type of AtMethod and return type of SizeMethod |
AtMethod | Member function type of the element accessor; expected to accept a SizeType index and return a ValueType |
SizeMethod | Member function type of the size accessor; expected to return a SizeType |
Definition at line 519 of file pyiteratorrange.h.