Changeset 881 for trunk/yat/utility/Iterator.h
 Timestamp:
 Sep 22, 2007, 10:22:36 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/Iterator.h
r880 r881 35 35 @brief Iterator 36 36 */ 37 template<typename Container>37 template<typename return_type, typename Container> 38 38 class Iterator 39 39 { … … 52 52 : container_(&container), index_(index) {} 53 53 54 re ference operator*(void) const { return container_>operator()(index_); }54 return_type operator*(void) const { return container_>operator()(index_); } 55 55 const Iterator& operator++(void) { ++index_; return *this; } 56 56 Iterator operator++(int) 57 { Iterator< Container> tmp(*this); ++index_; return tmp;}57 { Iterator<return_type, Container> tmp(*this); ++index_; return tmp;} 58 58 Iterator& operator+=(int n) { index_+=n; return *this; } 59 59 Iterator operator+(int n) 60 { return Iterator< Container>(*container_, index_+n); }60 { return Iterator<return_type, Container>(*container_, index_+n); } 61 61 Iterator operator(int) 62 { Iterator< Container> tmp(*this); index_; return tmp;}62 { Iterator<return_type, Container> tmp(*this); index_; return tmp;} 63 63 Iterator operator(void) { index_; return *this; } 64 64 Iterator& operator=(int n) { index_=n; return *this; } 65 65 Iterator operator(size_t n) 66 { return Iterator< Container>(*container_, index_n); }66 { return Iterator<return_type, Container>(*container_, index_n); } 67 67 size_t operator(const Iterator& rhs) 68 68 { return index_rhs.index_; } 69 69 70 bool equal(const Iterator< Container>& other) const70 bool equal(const Iterator<return_type, Container>& other) const 71 71 { return container_==other.container_ && index_==other.index_; } 72 72 73 bool less(const Iterator< Container>& other) const73 bool less(const Iterator<return_type, Container>& other) const 74 74 { return index_<other.index_; } 75 76 operator Iterator<const double, const Container> () 77 { return Iterator<const double, const Container>(*container_, index_); } 75 78 76 79 private: … … 83 86 }; 84 87 85 template <typename T>86 inline bool operator==(const Iterator<T>& lhs,87 const Iterator<T>& rhs)88 89 90 88 template <typename T1, typename T2> 89 inline bool operator==(const Iterator<T1,T2>& lhs, 90 const Iterator<T1,T2>& rhs) 91 { 92 return lhs.equal(rhs); 93 } 91 94 92 template <typename T>93 inline bool operator!=(const Iterator<T>& lhs,94 const Iterator<T>& rhs)95 96 97 98 99 100 template <typename T>101 inline bool operator<(const Iterator<T>& lhs,102 const Iterator<T>& rhs)103 104 105 106 107 108 template <typename T>109 inline bool operator<=(const Iterator<T>& lhs,110 const Iterator<T>& rhs)111 112 113 114 115 116 template <typename T>117 inline bool operator>(const Iterator<T>& lhs,118 const Iterator<T>& rhs)119 120 121 122 123 124 template <typename T>125 inline bool operator>=(const Iterator<T>& lhs,126 const Iterator<T>& rhs)127 128 129 95 template <typename T1, typename T2> 96 inline bool operator!=(const Iterator<T1,T2>& lhs, 97 const Iterator<T1,T2>& rhs) 98 { 99 return !(lhs==rhs); 100 } 101 102 103 template <typename T1, typename T2> 104 inline bool operator<(const Iterator<T1,T2>& lhs, 105 const Iterator<T1,T2>& rhs) 106 { 107 return lhs<rhs; 108 } 109 110 111 template <typename T1, typename T2> 112 inline bool operator<=(const Iterator<T1,T2>& lhs, 113 const Iterator<T1,T2>& rhs) 114 { 115 return !(rhs<lhs); 116 } 117 118 119 template <typename T1, typename T2> 120 inline bool operator>(const Iterator<T1,T2>& lhs, 121 const Iterator<T1,T2>& rhs) 122 { 123 return rhs<lhs; 124 } 125 126 127 template <typename T1, typename T2> 128 inline bool operator>=(const Iterator<T1,T2>& lhs, 129 const Iterator<T1,T2>& rhs) 130 { 131 return !(lhs<rhs); 132 } 130 133 131 134
Note: See TracChangeset
for help on using the changeset viewer.