Boost logo

Boost :

From: Toon Knapen (toon_at_[hidden])
Date: 2001-08-27 07:34:39


If others would also be interested I would like to see iterator_adaptors
extended with a strided_iterator_policy.

Using the strided_iterator_policy, every increment of the iterator will
advance the iterator according a user defined 'stride'

{ // begin example :

   template < int N >
   class stride_iterator_policy : public boost::default_iterator_policies
   {
   public:
     template <class BaseType>
     static void increment(BaseType& x) { std::advance( x, N ); }
   };

boost::iterator_adaptor< RealValues::const_iterator,
   stride_iterator_policy<3> > dof_it( dof_values.begin() );
prod = std::inner_product( shapes.begin(), shapes.end(), dof_it, 0.0 );

} // end example

The iterator is here used to traverse the first row of every column in a
column-major matrix.

This type of iterator is frequently used within for instance matrix
operations.

toon


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk