00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #ifndef MLN_UTIL_INDEX_HH
00027 # define MLN_UTIL_INDEX_HH
00028 
00038 # include <mln/core/concept/object.hh>
00039 
00040 
00041 namespace mln
00042 {
00043 
00044   namespace util
00045   {
00046 
00047     
00048     template <typename Tag> struct dindex_;
00049 
00050 
00054     template <typename Tag = void>
00055     struct index_ 
00056     {
00057       typedef Object<void> category;
00058 
00059       typedef dindex_<Tag> dpsite;
00060 
00061       typedef int coord;
00062       enum { dim = 1 };
00063 
00064       int i_;
00065 
00066       index_() {}
00067       index_(int i) : i_(i) {}
00068 
00069       index_<Tag>& operator++()
00070       {
00071         ++i_; 
00072         return *this;
00073       }
00074 
00075       index_<Tag> operator++(int)
00076       {
00077         index_<Tag> cpy(i_ + 1);
00078         ++i_; 
00079         return cpy;
00080       }
00081 
00082       index_<Tag>& operator--()
00083       {
00084         --i_; 
00085         return *this;
00086       }
00087 
00088       index_<Tag> operator--(int)
00089       {
00090         index_<Tag> cpy(i_ + 1);
00091         --i_; 
00092         return cpy;
00093       }
00094 
00095       bool operator<(const index_& rhs) const
00096       {
00097         return i_ < rhs.i_;
00098       }
00099 
00100       bool operator<(int i) const
00101       {
00102         return i_ < i;
00103       }
00104 
00105       operator int() const { return i_; }
00106     };
00107 
00108     typedef index_<void> index;
00109 
00110 
00111 
00112 # ifndef MLN_INCLUDE_ONLY
00113 
00114     
00115 
00116 # endif // ! MLN_INCLUDE_ONLY
00117 
00118   } 
00119 
00120 } 
00121 
00122 
00123 # include <mln/util/dindex.hh>
00124 
00125 
00126 #endif // ! MLN_UTIL_INDEX_HH