| 26 | |
| 27 | template <typename PROXY> |
| 28 | class Proxy_Iterator { |
| 29 | public: |
| 30 | typedef PROXY& reference ; |
| 31 | typedef PROXY* pointer ; |
| 32 | typedef R_xlen_t difference_type ; |
| 33 | typedef PROXY value_type; |
| 34 | typedef std::random_access_iterator_tag iterator_category ; |
| 35 | |
| 36 | Proxy_Iterator( ): proxy(){} ; |
| 37 | Proxy_Iterator( const Proxy_Iterator& other) : proxy( other.proxy){} |
| 38 | Proxy_Iterator( const PROXY& proxy_ ) : proxy( proxy_ ){} ; |
| 39 | |
| 40 | Proxy_Iterator& operator=( const Proxy_Iterator& other ){ |
| 41 | proxy.import( other.proxy ) ; |
| 42 | return *this ; |
| 43 | } |
| 44 | |
| 45 | inline Proxy_Iterator& operator++(){ |
| 46 | proxy.move(1) ; |
| 47 | return *this ; |
| 48 | } |
| 49 | inline Proxy_Iterator operator++(int){ |
| 50 | Proxy_Iterator orig(*this) ; |
| 51 | ++(*this) ; |
| 52 | return orig ; |
| 53 | } |
| 54 | |
| 55 | inline Proxy_Iterator& operator--(){ |
| 56 | proxy.move(-1) ; |
| 57 | return *this ; |
| 58 | } |
| 59 | inline Proxy_Iterator operator--(int){ |
| 60 | Proxy_Iterator orig(*this) ; |
| 61 | --(*this) ; |
| 62 | return orig ; |
| 63 | } |
| 64 | |
| 65 | inline Proxy_Iterator operator+(difference_type n) const { |
| 66 | return Proxy_Iterator( PROXY(*proxy.parent, proxy.index + n) ) ; |
| 67 | } |
| 68 | inline Proxy_Iterator operator-(difference_type n) const { |
| 69 | return Proxy_Iterator( PROXY(*proxy.parent, proxy.index - n) ) ; |
| 70 | } |
| 71 | |
| 72 | inline Proxy_Iterator& operator+=(difference_type n) { |
| 73 | proxy.move( n ) ; |
| 74 | return *this ; |
| 75 | } |
| 76 | inline Proxy_Iterator& operator-=(difference_type n) { |
| 77 | proxy.move( -n ) ; |
| 78 | return *this ; |
| 79 | } |
| 80 | |
| 81 | inline reference operator*() { |
| 82 | return proxy ; |
| 83 | } |
| 84 | inline pointer operator->(){ |
| 85 | return &proxy ; |