00001
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027
00028 #ifndef __CIRCULATOR_H__
00029 #define __CIRCULATOR_H__
00030
00031 namespace siscone{
00032
00035 template<class T> class circulator {
00036
00037 public:
00038 inline circulator(T here, T begin, T end) : m_here(here), m_begin(begin), m_end(end) {}
00039
00040 inline circulator(const circulator<T> & other) : m_here(other.m_here), m_begin(other.m_begin), m_end(other.m_end) {}
00041
00043 void set_position(const circulator<T> & other) {m_here = other.m_here;}
00044 void set_position(T pointer) {m_here = pointer;}
00045
00046 T operator()() {return m_here;}
00047
00048 inline circulator<T> & operator++() {
00049 ++m_here;
00050 if (m_here == m_end) m_here = m_begin;
00051 return *this;
00052 }
00053
00054 inline circulator<T> & operator--() {
00055 if (m_here == m_begin) m_here = m_end;
00056 --m_here;
00057 return *this;
00058 }
00059
00061 bool operator==(const circulator & other) const {return m_here == other.m_here;}
00063 bool operator!=(const circulator & other) const {return m_here != other.m_here;}
00064
00065 private:
00066 T m_here, m_begin, m_end;
00067 };
00068
00069 }
00070
00071 #endif // __CIRCULATOR_H__