00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_STRIDED_BASE_CURSOR_INCLUDE
00013 #define MTL_STRIDED_BASE_CURSOR_INCLUDE
00014
00015 #include <boost/numeric/mtl/detail/base_cursor.hpp>
00016
00017 namespace mtl { namespace detail {
00018
00019 template <class Key> struct strided_base_cursor
00020 : base_cursor<Key>
00021 {
00022 typedef Key key_type;
00023 typedef base_cursor<Key> base;
00024 typedef strided_base_cursor self;
00025
00026 strided_base_cursor () {}
00027 strided_base_cursor (key_type key, std::size_t stride)
00028 : base(key), stride(stride)
00029 {}
00030
00031 self& operator++ ()
00032 {
00033 this->key+= stride; return *this;
00034 }
00035 self operator++ (int)
00036 {
00037 self tmp = *this;
00038 this->key+= stride;
00039 return tmp;
00040 }
00041 self& operator-- ()
00042 {
00043 this->key-= stride;
00044 return *this;
00045 }
00046 self operator-- (int)
00047 {
00048 self tmp = *this;
00049 this->key-= stride;
00050 return tmp;
00051 }
00052 self& operator+=(int n)
00053 {
00054 this->key += stride * n;
00055 return *this;
00056 }
00057 self operator+(int n) const
00058 {
00059 self tmp(*this);
00060 tmp+= n;
00061 return tmp;
00062 }
00063 self& operator-=(int n)
00064 {
00065 this->key -= stride * n;
00066 return *this;
00067 }
00068
00069 int operator-(const self& cc) const
00070 {
00071 return (this->key - cc.key) / stride;
00072 }
00073
00074 std::size_t stride;
00075 };
00076
00077 }}
00078
00079 #endif // MTL_STRIDED_BASE_CURSOR_INCLUDE