00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_BASE_CURSOR_INCLUDE
00013 #define MTL_BASE_CURSOR_INCLUDE
00014
00015 namespace mtl { namespace detail {
00016
00017
00018 template <class Key> class base_cursor
00019 {
00020 public:
00021 typedef Key key_type;
00022 typedef base_cursor self;
00023
00024 base_cursor () {}
00025 base_cursor (key_type key) : key(key) {}
00026
00027 key_type operator*() const
00028 {
00029 return key;
00030 }
00031
00032 self& operator++ ()
00033 {
00034 ++key; return *this;
00035 }
00036 self operator++ (int)
00037 {
00038 self tmp = *this;
00039 ++key;
00040 return tmp;
00041 }
00042 self& operator-- ()
00043 {
00044 --key;
00045 return *this;
00046 }
00047 self operator-- (int)
00048 {
00049 self tmp = *this;
00050 --key;
00051 return tmp;
00052 }
00053 self& operator+=(int n)
00054 {
00055 key += n;
00056 return *this;
00057 }
00058
00059 self operator+(int n) const
00060 {
00061 self tmp = *this;
00062 tmp+= n;
00063 return tmp;
00064 }
00065
00066 self& operator-=(int n)
00067 {
00068 key -= n;
00069 return *this;
00070 }
00071
00072 int operator-(const self& cc) const
00073 {
00074 return this->key - cc.key;
00075 }
00076
00077 bool operator==(const self& cc) const
00078 {
00079 return key == cc.key;
00080 }
00081
00082 bool operator!=(const self& cc) const
00083 {
00084 return !(*this == cc);
00085 }
00086
00087
00088
00089
00090 key_type key;
00091 };
00092
00093
00094
00095 }}
00096
00097 #endif // MTL_BASE_CURSOR_INCLUDE
00098
00099