45 #include "Moocho_ConfigDefs.hpp"
47 namespace StrideIterPack {
57 template<
class T_iterator_type,
class T_value_type,
class T_reference_type
58 ,
class T_pointer_type,
class T_difference_type>
92 template<
class Iter,
class Val,
class Ref,
class Ptr,
class Diff>
96 template<
class Iter,
class Val,
class Ref,
class Ptr,
class Diff>
98 current_ = rhs.
current(); stride_ = rhs.
stride();
return *
this;
116 return current_[n * stride_];
146 return stride_iter(current_ + n * stride_, stride_);
150 return stride_iter(current_ + n * stride_, stride_);
154 current_ += n * stride_;
159 return stride_iter(current_ - n * stride_, stride_);
163 return stride_iter(current_ - n * stride_, stride_);
167 current_ -= n * stride_;
175 return (current_ - itr.current_)/stride_;
209 template<
class Iter,
class Val,
class Ref,
class Ptr,
class Diff>
210 inline const stride_iter<Iter,Val,Ref,Ptr,Diff> operator+(Diff n
211 ,
const stride_iter<Iter,Val,Ref,Ptr,Diff> itr)
217 template<
class Iter,
class Val,
class Ref,
class Ptr,
class Diff>
218 inline bool operator<(const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr1,
219 const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr2)
221 return itr1.operator->() < itr2.operator->();
224 template<
class Iter,
class Val,
class Ref,
class Ptr,
class Diff>
225 inline bool operator<=(const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr1,
226 const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr2)
228 return itr1.operator->() <= itr2.operator->();
231 template<
class Iter,
class Val,
class Ref,
class Ptr,
class Diff>
232 inline bool operator>(
const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr1,
233 const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr2)
235 return itr1.operator->() > itr2.operator->();
238 template<
class Iter,
class Val,
class Ref,
class Ptr,
class Diff>
239 inline bool operator>=(
const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr1,
240 const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr2)
242 return itr1.operator->() >= itr2.operator->();
245 template<
class Iter,
class Val,
class Ref,
class Ptr,
class Diff>
246 inline bool operator==(
const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr1,
247 const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr2)
249 return itr1.operator->() == itr2.operator->();
252 template<
class Iter,
class Val,
class Ref,
class Ptr,
class Diff>
253 inline bool operator!=(
const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr1,
254 const stride_iter<Iter,Val,Ref,Ptr,Diff>& itr2)
256 return itr1.operator->() != itr2.operator->();
263 #endif // STRIDE_ITER_H
stride_iter & operator-=(difference_type n)
itr -= n
stride_iter(iterator_type current, difference_type stride)
constructs to the desired sliced iterator
std::random_access_iterator_tag iterator_category
iterator_type current() const
T_reference_type reference
stride_iter & operator--()
–itr
stride_iter(const stride_iter< Iter, Val, Ref, Ptr, Diff > &rhs)
convert type of iterators (mainly for non-const to const)
stride_iter & operator++()
++itr
C++ Standard Library compatable iterator class for accesing nonunit stride arrays of data...
stride_iter operator-(difference_type n)
itr - n
const stride_iter operator--(int)
itr–
const stride_iter operator+(difference_type n) const
itr + n
reference operator*() const
difference_type stride() const
const stride_iter operator-(difference_type n) const
itr - n
stride_iter()
constructs to a null iterator
T_iterator_type iterator_type
pointer operator->() const
const stride_iter operator++(int)
itr++
stride_iter & operator=(const stride_iter< Iter, Val, Ref, Ptr, Diff > &rhs)
assign different types of iterators (mainly for non-const to const)
difference_type operator-(const stride_iter &itr) const
distance = itr1 - itr2 (distance between elements)
stride_iter operator+(difference_type n)
itr + n
stride_iter(iterator_type current)
constructs to the standard iterator (behaves as) (increment 1). Allows conversion from iterator...
stride_iter & operator+=(difference_type n)
itr += n
reference operator[](difference_type n) const
T_difference_type difference_type