| 178 | }; |
| 179 | |
| 180 | class const_iterator { |
| 181 | private: |
| 182 | mutable iterator rep_; // Share state and logic with non-const iterator. |
| 183 | public: |
| 184 | typedef typename FlatMap::difference_type difference_type; |
| 185 | typedef typename FlatMap::value_type value_type; |
| 186 | typedef typename FlatMap::const_pointer pointer; |
| 187 | typedef typename FlatMap::const_reference reference; |
| 188 | typedef ::std::forward_iterator_tag iterator_category; |
| 189 | |
| 190 | const_iterator() : rep_() {} |
| 191 | const_iterator(Bucket* start, Bucket* end) : rep_(start, end) {} |
| 192 | const_iterator(Bucket* b, Bucket* end, uint32 i) : rep_(b, end, i) {} |
| 193 | |
| 194 | reference operator*() const { return *rep_.val(); } |
| 195 | pointer operator->() const { return rep_.val(); } |
| 196 | bool operator==(const const_iterator& x) const { return rep_ == x.rep_; } |
| 197 | bool operator!=(const const_iterator& x) const { return rep_ != x.rep_; } |
| 198 | const_iterator& operator++() { |
| 199 | ++rep_; |
| 200 | return *this; |
| 201 | } |
| 202 | const_iterator operator++(int /*indicates postfix*/) { |
| 203 | const_iterator tmp(*this); |
| 204 | ++*this; |
| 205 | return tmp; |
| 206 | } |
| 207 | }; |
| 208 | |
| 209 | iterator begin() { return iterator(rep_.start(), rep_.limit()); } |
| 210 | iterator end() { return iterator(rep_.limit(), rep_.limit()); } |