Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
Public Methods | List of all members
cusp::strided_iterator< RandomAccessIterator > Class Template Reference

Detailed description

template<typename RandomAccessIterator>
class cusp::strided_iterator< RandomAccessIterator >

RandomAccessIterator for strided access to array entries.

Template Parameters
RandomAccessIteratorThe iterator type used to encapsulate the underlying data.
Overview
strided_iterator is an iterator which represents a pointer into a strided range entries in a underlying array. This iterator is useful for creating a strided sublist of entries from a larger iterator.
Example
The following code snippet demonstrates how to create a strided_iterator whose value_type is int and whose values are gather from a counting_array.
#include <cusp/array1d.h>
#include <iostream>
int main(void)
{
cusp::strided_iterator<Iterator> iter(a.begin(), a.end(), 5);
std::cout << iter[0] << std::endl; // returns 0
std::cout << iter[1] << std::endl; // returns 5
std::cout << iter[3] << std::endl; // returns 15
return 0;
}

Definition at line 78 of file strided_iterator.h.

#include <strided_iterator.h>

Public Methods

 strided_iterator (void)
 Null constructor initializes this strided_iterator's stride to zero.
 
 strided_iterator (RandomAccessIterator first, RandomAccessIterator last, difference_type stride)
 This constructor builds a strided_iterator from a range. More...
 
iterator begin (void) const
 This method returns an iterator pointing to the beginning of this strided sequence of entries. More...
 
iterator end (void) const
 This method returns an iterator pointing to one element past the last of this strided sequence of entries. More...
 
reference operator[] (size_type n) const
 Subscript access to the data contained in this iterator. More...
 

Constructor & Destructor Documentation

template<typename RandomAccessIterator>
cusp::strided_iterator< RandomAccessIterator >::strided_iterator ( RandomAccessIterator  first,
RandomAccessIterator  last,
difference_type  stride 
)
inline

This constructor builds a strided_iterator from a range.

Parameters
firstThe beginning of the range.
lastThe end of the range.
strideThe stride between consecutive entries in the iterator.

Definition at line 109 of file strided_iterator.h.

Member Function Documentation

template<typename RandomAccessIterator>
iterator cusp::strided_iterator< RandomAccessIterator >::begin ( void  ) const
inline

This method returns an iterator pointing to the beginning of this strided sequence of entries.

Returns
mStart

Definition at line 116 of file strided_iterator.h.

template<typename RandomAccessIterator>
iterator cusp::strided_iterator< RandomAccessIterator >::end ( void  ) const
inline

This method returns an iterator pointing to one element past the last of this strided sequence of entries.

Returns
mEnd

Definition at line 125 of file strided_iterator.h.

template<typename RandomAccessIterator>
reference cusp::strided_iterator< RandomAccessIterator >::operator[] ( size_type  n) const
inline

Subscript access to the data contained in this iterator.

Parameters
nThe index of the element for which data should be accessed.
Returns
Read/write reference to data.

This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined.

Definition at line 138 of file strided_iterator.h.