| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ITERATOR_UTIL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ITERATOR_UTIL_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ITERATOR_UTIL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ITERATOR_UTIL_H_ |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/array.h" | 10 #include "mojo/public/cpp/bindings/array.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 return *this; | 56 return *this; |
| 57 } | 57 } |
| 58 Iterator operator--(int) { | 58 Iterator operator--(int) { |
| 59 Iterator original = *this; | 59 Iterator original = *this; |
| 60 --it_; | 60 --it_; |
| 61 return original; | 61 return original; |
| 62 } | 62 } |
| 63 bool operator==(const Iterator& o) const { return o.it_ == it_; } | 63 bool operator==(const Iterator& o) const { return o.it_ == it_; } |
| 64 bool operator!=(const Iterator& o) const { return o.it_ != it_; } | 64 bool operator!=(const Iterator& o) const { return o.it_ != it_; } |
| 65 typename Map<K, V>::KeyConstRefType operator*() { return it_.GetKey(); } | 65 typename Map<K, V>::KeyConstRefType operator*() { return it_.GetKey(); } |
| 66 typename Map<K, V>::KeyConstRefType operator->() { return operator*(); } | 66 const K* operator->() { return &it_.GetKey(); } |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 typename Map<K, V>::MapIterator it_; | 69 typename Map<K, V>::MapIterator it_; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 explicit MapKeyIterator(Map<K, V>* map) : map_(map) { MOJO_DCHECK(map); } | 72 explicit MapKeyIterator(Map<K, V>* map) : map_(map) { MOJO_DCHECK(map); } |
| 73 | 73 |
| 74 size_t size() const { return map_->size(); } | 74 size_t size() const { return map_->size(); } |
| 75 Iterator begin() const { return Iterator{map_->begin()}; } | 75 Iterator begin() const { return Iterator{map_->begin()}; } |
| 76 Iterator end() const { return Iterator{map_->end()}; } | 76 Iterator end() const { return Iterator{map_->end()}; } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 101 return *this; | 101 return *this; |
| 102 } | 102 } |
| 103 Iterator operator--(int) { | 103 Iterator operator--(int) { |
| 104 Iterator original = *this; | 104 Iterator original = *this; |
| 105 --it_; | 105 --it_; |
| 106 return original; | 106 return original; |
| 107 } | 107 } |
| 108 bool operator==(const Iterator& o) const { return o.it_ == it_; } | 108 bool operator==(const Iterator& o) const { return o.it_ == it_; } |
| 109 bool operator!=(const Iterator& o) const { return o.it_ != it_; } | 109 bool operator!=(const Iterator& o) const { return o.it_ != it_; } |
| 110 typename Map<K, V>::ValueRefType operator*() { return it_.GetValue(); } | 110 typename Map<K, V>::ValueRefType operator*() { return it_.GetValue(); } |
| 111 typename Map<K, V>::ValueRefType operator->() { return operator*(); } | 111 V* operator->() { return &it_.GetValue(); } |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 typename Map<K, V>::MapIterator it_; | 114 typename Map<K, V>::MapIterator it_; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 explicit MapValueIterator(Map<K, V>* map) : map_(map) { MOJO_DCHECK(map); } | 117 explicit MapValueIterator(Map<K, V>* map) : map_(map) { MOJO_DCHECK(map); } |
| 118 size_t size() const { return map_->size(); } | 118 size_t size() const { return map_->size(); } |
| 119 Iterator begin() const { return Iterator{map_->begin()}; } | 119 Iterator begin() const { return Iterator{map_->begin()}; } |
| 120 Iterator end() const { return Iterator{map_->end()}; } | 120 Iterator end() const { return Iterator{map_->end()}; } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 Map<K, V>* const map_; | 123 Map<K, V>* const map_; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 } // namespace internal | 126 } // namespace internal |
| 127 } // namespace mojo | 127 } // namespace mojo |
| 128 | 128 |
| 129 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ITERATOR_UTIL_H_ | 129 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ITERATOR_UTIL_H_ |
| OLD | NEW |