1 #ifndef _theplu_yat_utility_stride_iterator_ 2 #define _theplu_yat_utility_stride_iterator_ 26 #include <boost/concept_check.hpp> 27 #include <boost/iterator/iterator_adaptor.hpp> 28 #include <boost/iterator/iterator_concepts.hpp> 49 template<
typename RandomAccessIterator>
51 :
public boost::iterator_adaptor<StrideIterator<RandomAccessIterator>
52 , RandomAccessIterator>
54 typedef boost::iterator_adaptor<StrideIterator<RandomAccessIterator>,
70 using boost_concepts::RandomAccessTraversal;
71 using boost_concepts::ReadableIterator;
72 BOOST_CONCEPT_ASSERT((ReadableIterator<RandomAccessIterator>));
73 BOOST_CONCEPT_ASSERT((RandomAccessTraversal<RandomAccessIterator>));
100 typename boost::enable_if_convertible<I2
101 , RandomAccessIterator>::type* = 0 )
103 stride_(other.
stride()) {}
111 this->base_reference() = rhs.base();
118 inline size_t stride(
void)
const {
return stride_; }
122 friend class boost::iterator_core_access;
127 typedef typename StrideIterator::iterator_adaptor_::difference_type
130 void advance(
typename super_t::difference_type n)
131 { this->base_reference() += stride_*n; }
133 void decrement(
void) { this->base_reference()-=stride_; }
135 template <
class OtherIterator>
136 typename super_t::difference_type
137 distance_to(
const StrideIterator<OtherIterator>& other)
const 140 return (other.base() - this->base() )/static_cast<int>(stride_);
143 void increment(
void) { this->base_reference()+=stride_; }
StrideIterator & operator=(const StrideIterator &rhs)
Assignment operator.
Definition: StrideIterator.h:108
StrideIterator(size_t stride=1)
default constructor
Definition: StrideIterator.h:67
The Department of Theoretical Physics namespace as we define it.
size_t stride(void) const
Definition: StrideIterator.h:118
StrideIterator(StrideIterator< I2 > other, typename boost::enable_if_convertible< I2, RandomAccessIterator >::type *=0)
Conversion constructor.
Definition: StrideIterator.h:99
StrideIterator(const StrideIterator &other)
Copy constructor.
Definition: StrideIterator.h:86
RandomAccessIterator iterator_type
type of underlying iterator
Definition: StrideIterator.h:60
StrideIterator(RandomAccessIterator p, size_t stride=1)
Constructor.
Definition: StrideIterator.h:79
Adaptor using a stride on underlying iterator.
Definition: StrideIterator.h:50