Changeset 883
- Timestamp:
- Sep 23, 2007, 12:05:41 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/iterator_test.cc
r882 r883 51 51 utility::vector::const_iterator ci = vec.begin(); 52 52 ci = begin; 53 //if (begin!=ci)54 //ok = false;55 53 if (begin!=ci) 54 ok = false; 55 56 56 utility::vector::iterator end=vec.end(); 57 57 std::sort(begin, end); … … 65 65 if (!ok) 66 66 *message << "iterator test failed" << std::endl; 67 67 68 68 return (ok ? 0 : -1); 69 69 } -
trunk/yat/utility/Iterator.h
r881 r883 68 68 { return index_-rhs.index_; } 69 69 70 bool equal(const Iterator<return_type, Container>& other) const71 { return container_==other.container_ && index_==other.index_; }72 73 70 bool less(const Iterator<return_type, Container>& other) const 74 71 { return index_<other.index_; } … … 77 74 { return Iterator<const double, const Container>(*container_, index_); } 78 75 76 79 77 private: 80 78 Container* container_; 81 79 size_t index_; 82 83 80 // Using compiler generated copy 84 81 //Iterator(const Iterator&); 85 82 //Iterator& operator=(const Iterator&); 83 84 85 public: 86 friend bool operator==(const Iterator<return_type, Container>& lhs, 87 const Iterator<return_type, Container>& rhs) 88 { return lhs.container_==rhs.container_ && lhs.index_==rhs.index_; } 89 90 friend bool operator!=(const Iterator<return_type, Container>& lhs, 91 const Iterator<return_type, Container>& rhs) 92 { return !(lhs.container_==rhs.container_ && lhs.index_==rhs.index_); } 93 94 friend bool operator<(const Iterator<return_type, Container>& lhs, 95 const Iterator<return_type, Container>& rhs) 96 { return lhs.index_<rhs.index_; } 97 98 friend bool operator<=(const Iterator<return_type, Container>& lhs, 99 const Iterator<return_type, Container>& rhs) 100 { return lhs.index_<=rhs.index_; } 101 102 friend bool operator>(const Iterator<return_type, Container>& lhs, 103 const Iterator<return_type, Container>& rhs) 104 { return lhs.index_>rhs.index_; } 105 106 friend bool operator>=(const Iterator<return_type, Container>& lhs, 107 const Iterator<return_type, Container>& rhs) 108 { return lhs.index_>=rhs.index_; } 109 110 111 86 112 }; 87 113 114 /* 88 115 template <typename T1, typename T2> 89 inlinebool operator==(const Iterator<T1,T2>& lhs,116 bool operator==(const Iterator<T1,T2>& lhs, 90 117 const Iterator<T1,T2>& rhs) 91 118 { … … 94 121 95 122 template <typename T1, typename T2> 96 inlinebool operator!=(const Iterator<T1,T2>& lhs,123 bool operator!=(const Iterator<T1,T2>& lhs, 97 124 const Iterator<T1,T2>& rhs) 98 125 { … … 102 129 103 130 template <typename T1, typename T2> 104 inlinebool operator<(const Iterator<T1,T2>& lhs,105 131 bool operator<(const Iterator<T1,T2>& lhs, 132 const Iterator<T1,T2>& rhs) 106 133 { 107 134 return lhs<rhs; … … 110 137 111 138 template <typename T1, typename T2> 112 inlinebool operator<=(const Iterator<T1,T2>& lhs,113 139 bool operator<=(const Iterator<T1,T2>& lhs, 140 const Iterator<T1,T2>& rhs) 114 141 { 115 142 return !(rhs<lhs); … … 118 145 119 146 template <typename T1, typename T2> 120 inlinebool operator>(const Iterator<T1,T2>& lhs,121 147 bool operator>(const Iterator<T1,T2>& lhs, 148 const Iterator<T1,T2>& rhs) 122 149 { 123 150 return rhs<lhs; … … 126 153 127 154 template <typename T1, typename T2> 128 inlinebool operator>=(const Iterator<T1,T2>& lhs,129 155 bool operator>=(const Iterator<T1,T2>& lhs, 156 const Iterator<T1,T2>& rhs) 130 157 { 131 158 return !(lhs<rhs); 132 159 } 133 160 */ 134 161 135 162 }}} // of namespace utility, yat, and theplu
Note: See TracChangeset
for help on using the changeset viewer.