Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: third_party/WebKit/Source/wtf/HashIterators.h

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/HashFunctions.h ('k') | third_party/WebKit/Source/wtf/HashMap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 10 matching lines...) Expand all
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef WTF_HashIterators_h 26 #ifndef WTF_HashIterators_h
27 #define WTF_HashIterators_h 27 #define WTF_HashIterators_h
28 28
29 namespace WTF { 29 namespace WTF {
30 30
31 template <typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstKeysIterator; 31 template <typename HashTableType, typename KeyType, typename MappedType>
32 template <typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstValuesIterator; 32 struct HashTableConstKeysIterator;
33 template <typename HashTableType, typename KeyType, typename MappedType> struct HashTableKeysIterator; 33 template <typename HashTableType, typename KeyType, typename MappedType>
34 template <typename HashTableType, typename KeyType, typename MappedType> struct HashTableValuesIterator; 34 struct HashTableConstValuesIterator;
35 template <typename HashTableType, typename KeyType, typename MappedType>
36 struct HashTableKeysIterator;
37 template <typename HashTableType, typename KeyType, typename MappedType>
38 struct HashTableValuesIterator;
35 39
36 template <typename HashTableType, typename KeyType, typename MappedType> 40 template <typename HashTableType, typename KeyType, typename MappedType>
37 struct HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, Mapped Type>> { 41 struct HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, Mapped Type>> {
38 private: 42 private:
39 typedef KeyValuePair<KeyType, MappedType> ValueType; 43 typedef KeyValuePair<KeyType, MappedType> ValueType;
40 public: 44
41 typedef HashTableConstKeysIterator<HashTableType, KeyType, MappedType> Keys; 45 public:
42 typedef HashTableConstValuesIterator<HashTableType, KeyType, MappedType> Val ues; 46 typedef HashTableConstKeysIterator<HashTableType, KeyType, MappedType> Keys;
43 47 typedef HashTableConstValuesIterator<HashTableType, KeyType, MappedType> Value s;
44 HashTableConstIteratorAdapter() {} 48
45 HashTableConstIteratorAdapter(const typename HashTableType::const_iterator& impl) : m_impl(impl) {} 49 HashTableConstIteratorAdapter() {}
46 50 HashTableConstIteratorAdapter(const typename HashTableType::const_iterator& im pl)
47 const ValueType* get() const { return (const ValueType*)m_impl.get(); } 51 : m_impl(impl) {}
48 const ValueType& operator*() const { return *get(); } 52
49 const ValueType* operator->() const { return get(); } 53 const ValueType* get() const { return (const ValueType*)m_impl.get(); }
50 54 const ValueType& operator*() const { return *get(); }
51 HashTableConstIteratorAdapter& operator++() { ++m_impl; return *this; } 55 const ValueType* operator->() const { return get(); }
52 // postfix ++ intentionally omitted 56
53 57 HashTableConstIteratorAdapter& operator++() {
54 Keys keys() { return Keys(*this); } 58 ++m_impl;
55 Values values() { return Values(*this); } 59 return *this;
56 60 }
57 typename HashTableType::const_iterator m_impl; 61 // postfix ++ intentionally omitted
62
63 Keys keys() { return Keys(*this); }
64 Values values() { return Values(*this); }
65
66 typename HashTableType::const_iterator m_impl;
58 }; 67 };
59 68
60 template <typename HashTableType, typename KeyType, typename MappedType> 69 template <typename HashTableType, typename KeyType, typename MappedType>
61 struct HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType> > { 70 struct HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType> > {
62 private: 71 private:
63 typedef KeyValuePair<KeyType, MappedType> ValueType; 72 typedef KeyValuePair<KeyType, MappedType> ValueType;
64 public: 73
65 typedef HashTableKeysIterator<HashTableType, KeyType, MappedType> Keys; 74 public:
66 typedef HashTableValuesIterator<HashTableType, KeyType, MappedType> Values; 75 typedef HashTableKeysIterator<HashTableType, KeyType, MappedType> Keys;
67 76 typedef HashTableValuesIterator<HashTableType, KeyType, MappedType> Values;
68 HashTableIteratorAdapter() {} 77
69 HashTableIteratorAdapter(const typename HashTableType::iterator& impl) : m_i mpl(impl) {} 78 HashTableIteratorAdapter() {}
70 79 HashTableIteratorAdapter(const typename HashTableType::iterator& impl)
71 ValueType* get() const { return (ValueType*)m_impl.get(); } 80 : m_impl(impl) {}
72 ValueType& operator*() const { return *get(); } 81
73 ValueType* operator->() const { return get(); } 82 ValueType* get() const { return (ValueType*)m_impl.get(); }
74 83 ValueType& operator*() const { return *get(); }
75 HashTableIteratorAdapter& operator++() { ++m_impl; return *this; } 84 ValueType* operator->() const { return get(); }
76 // postfix ++ intentionally omitted 85
77 86 HashTableIteratorAdapter& operator++() {
78 operator HashTableConstIteratorAdapter<HashTableType, ValueType>() 87 ++m_impl;
79 { 88 return *this;
80 typename HashTableType::const_iterator i = m_impl; 89 }
81 return i; 90 // postfix ++ intentionally omitted
82 } 91
83 92 operator HashTableConstIteratorAdapter<HashTableType, ValueType>() {
84 Keys keys() { return Keys(*this); } 93 typename HashTableType::const_iterator i = m_impl;
85 Values values() { return Values(*this); } 94 return i;
86 95 }
87 typename HashTableType::iterator m_impl; 96
97 Keys keys() { return Keys(*this); }
98 Values values() { return Values(*this); }
99
100 typename HashTableType::iterator m_impl;
88 }; 101 };
89 102
90 template <typename HashTableType, typename KeyType, typename MappedType> 103 template <typename HashTableType, typename KeyType, typename MappedType>
91 struct HashTableConstKeysIterator { 104 struct HashTableConstKeysIterator {
92 private: 105 private:
93 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, M appedType>> ConstIterator; 106 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, Map pedType>> ConstIterator;
94 107
95 public: 108 public:
96 HashTableConstKeysIterator(const ConstIterator& impl) : m_impl(impl) {} 109 HashTableConstKeysIterator(const ConstIterator& impl)
97 110 : m_impl(impl) {}
98 const KeyType* get() const { return &(m_impl.get()->key); } 111
99 const KeyType& operator*() const { return *get(); } 112 const KeyType* get() const { return &(m_impl.get()->key); }
100 const KeyType* operator->() const { return get(); } 113 const KeyType& operator*() const { return *get(); }
101 114 const KeyType* operator->() const { return get(); }
102 HashTableConstKeysIterator& operator++() { ++m_impl; return *this; } 115
103 // postfix ++ intentionally omitted 116 HashTableConstKeysIterator& operator++() {
104 117 ++m_impl;
105 ConstIterator m_impl; 118 return *this;
119 }
120 // postfix ++ intentionally omitted
121
122 ConstIterator m_impl;
106 }; 123 };
107 124
108 template <typename HashTableType, typename KeyType, typename MappedType> 125 template <typename HashTableType, typename KeyType, typename MappedType>
109 struct HashTableConstValuesIterator { 126 struct HashTableConstValuesIterator {
110 private: 127 private:
111 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, M appedType>> ConstIterator; 128 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, Map pedType>> ConstIterator;
112 129
113 public: 130 public:
114 HashTableConstValuesIterator(const ConstIterator& impl) : m_impl(impl) {} 131 HashTableConstValuesIterator(const ConstIterator& impl)
115 132 : m_impl(impl) {}
116 const MappedType* get() const { return &(m_impl.get()->value); } 133
117 const MappedType& operator*() const { return *get(); } 134 const MappedType* get() const { return &(m_impl.get()->value); }
118 const MappedType* operator->() const { return get(); } 135 const MappedType& operator*() const { return *get(); }
119 136 const MappedType* operator->() const { return get(); }
120 HashTableConstValuesIterator& operator++() { ++m_impl; return *this; } 137
121 // postfix ++ intentionally omitted 138 HashTableConstValuesIterator& operator++() {
122 139 ++m_impl;
123 ConstIterator m_impl; 140 return *this;
141 }
142 // postfix ++ intentionally omitted
143
144 ConstIterator m_impl;
124 }; 145 };
125 146
126 template <typename HashTableType, typename KeyType, typename MappedType> 147 template <typename HashTableType, typename KeyType, typename MappedType>
127 struct HashTableKeysIterator { 148 struct HashTableKeysIterator {
128 private: 149 private:
129 typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, Mapped Type>> Iterator; 150 typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedTy pe>> Iterator;
130 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, M appedType>> ConstIterator; 151 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, Map pedType>> ConstIterator;
131 152
132 public: 153 public:
133 HashTableKeysIterator(const Iterator& impl) : m_impl(impl) {} 154 HashTableKeysIterator(const Iterator& impl)
134 155 : m_impl(impl) {}
135 KeyType* get() const { return &(m_impl.get()->key); } 156
136 KeyType& operator*() const { return *get(); } 157 KeyType* get() const { return &(m_impl.get()->key); }
137 KeyType* operator->() const { return get(); } 158 KeyType& operator*() const { return *get(); }
138 159 KeyType* operator->() const { return get(); }
139 HashTableKeysIterator& operator++() { ++m_impl; return *this; } 160
140 // postfix ++ intentionally omitted 161 HashTableKeysIterator& operator++() {
141 162 ++m_impl;
142 operator HashTableConstKeysIterator<HashTableType, KeyType, MappedType>() 163 return *this;
143 { 164 }
144 ConstIterator i = m_impl; 165 // postfix ++ intentionally omitted
145 return i; 166
146 } 167 operator HashTableConstKeysIterator<HashTableType, KeyType, MappedType>() {
147 168 ConstIterator i = m_impl;
148 Iterator m_impl; 169 return i;
170 }
171
172 Iterator m_impl;
149 }; 173 };
150 174
151 template <typename HashTableType, typename KeyType, typename MappedType> 175 template <typename HashTableType, typename KeyType, typename MappedType>
152 struct HashTableValuesIterator { 176 struct HashTableValuesIterator {
153 private: 177 private:
154 typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, Mapped Type>> Iterator; 178 typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedTy pe>> Iterator;
155 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, M appedType>> ConstIterator; 179 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, Map pedType>> ConstIterator;
156 180
157 public: 181 public:
158 HashTableValuesIterator(const Iterator& impl) : m_impl(impl) {} 182 HashTableValuesIterator(const Iterator& impl)
159 183 : m_impl(impl) {}
160 MappedType* get() const { return &(m_impl.get()->value); } 184
161 MappedType& operator*() const { return *get(); } 185 MappedType* get() const { return &(m_impl.get()->value); }
162 MappedType* operator->() const { return get(); } 186 MappedType& operator*() const { return *get(); }
163 187 MappedType* operator->() const { return get(); }
164 HashTableValuesIterator& operator++() { ++m_impl; return *this; } 188
165 // postfix ++ intentionally omitted 189 HashTableValuesIterator& operator++() {
166 190 ++m_impl;
167 operator HashTableConstValuesIterator<HashTableType, KeyType, MappedType>() 191 return *this;
168 { 192 }
169 ConstIterator i = m_impl; 193 // postfix ++ intentionally omitted
170 return i; 194
171 } 195 operator HashTableConstValuesIterator<HashTableType, KeyType, MappedType>() {
172 196 ConstIterator i = m_impl;
173 Iterator m_impl; 197 return i;
174 }; 198 }
175 199
176 template <typename T, typename U, typename V> 200 Iterator m_impl;
177 inline bool operator==(const HashTableConstKeysIterator<T, U, V>& a, const HashT ableConstKeysIterator<T, U, V>& b) 201 };
178 { 202
179 return a.m_impl == b.m_impl; 203 template <typename T, typename U, typename V>
180 } 204 inline bool operator==(const HashTableConstKeysIterator<T, U, V>& a, const HashT ableConstKeysIterator<T, U, V>& b) {
181 205 return a.m_impl == b.m_impl;
182 template <typename T, typename U, typename V> 206 }
183 inline bool operator!=(const HashTableConstKeysIterator<T, U, V>& a, const HashT ableConstKeysIterator<T, U, V>& b) 207
184 { 208 template <typename T, typename U, typename V>
185 return a.m_impl != b.m_impl; 209 inline bool operator!=(const HashTableConstKeysIterator<T, U, V>& a, const HashT ableConstKeysIterator<T, U, V>& b) {
186 } 210 return a.m_impl != b.m_impl;
187 211 }
188 template <typename T, typename U, typename V> 212
189 inline bool operator==(const HashTableConstValuesIterator<T, U, V>& a, const Has hTableConstValuesIterator<T, U, V>& b) 213 template <typename T, typename U, typename V>
190 { 214 inline bool operator==(const HashTableConstValuesIterator<T, U, V>& a, const Has hTableConstValuesIterator<T, U, V>& b) {
191 return a.m_impl == b.m_impl; 215 return a.m_impl == b.m_impl;
192 } 216 }
193 217
194 template <typename T, typename U, typename V> 218 template <typename T, typename U, typename V>
195 inline bool operator!=(const HashTableConstValuesIterator<T, U, V>& a, const Has hTableConstValuesIterator<T, U, V>& b) 219 inline bool operator!=(const HashTableConstValuesIterator<T, U, V>& a, const Has hTableConstValuesIterator<T, U, V>& b) {
196 { 220 return a.m_impl != b.m_impl;
197 return a.m_impl != b.m_impl; 221 }
198 } 222
199 223 template <typename T, typename U, typename V>
200 template <typename T, typename U, typename V> 224 inline bool operator==(const HashTableKeysIterator<T, U, V>& a, const HashTableK eysIterator<T, U, V>& b) {
201 inline bool operator==(const HashTableKeysIterator<T, U, V>& a, const HashTableK eysIterator<T, U, V>& b) 225 return a.m_impl == b.m_impl;
202 { 226 }
203 return a.m_impl == b.m_impl; 227
204 } 228 template <typename T, typename U, typename V>
205 229 inline bool operator!=(const HashTableKeysIterator<T, U, V>& a, const HashTableK eysIterator<T, U, V>& b) {
206 template <typename T, typename U, typename V> 230 return a.m_impl != b.m_impl;
207 inline bool operator!=(const HashTableKeysIterator<T, U, V>& a, const HashTableK eysIterator<T, U, V>& b) 231 }
208 { 232
209 return a.m_impl != b.m_impl; 233 template <typename T, typename U, typename V>
210 } 234 inline bool operator==(const HashTableValuesIterator<T, U, V>& a, const HashTabl eValuesIterator<T, U, V>& b) {
211 235 return a.m_impl == b.m_impl;
212 template <typename T, typename U, typename V> 236 }
213 inline bool operator==(const HashTableValuesIterator<T, U, V>& a, const HashTabl eValuesIterator<T, U, V>& b) 237
214 { 238 template <typename T, typename U, typename V>
215 return a.m_impl == b.m_impl; 239 inline bool operator!=(const HashTableValuesIterator<T, U, V>& a, const HashTabl eValuesIterator<T, U, V>& b) {
216 } 240 return a.m_impl != b.m_impl;
217 241 }
218 template <typename T, typename U, typename V> 242
219 inline bool operator!=(const HashTableValuesIterator<T, U, V>& a, const HashTabl eValuesIterator<T, U, V>& b) 243 } // namespace WTF
220 { 244
221 return a.m_impl != b.m_impl; 245 #endif // WTF_HashIterators_h
222 }
223
224 } // namespace WTF
225
226 #endif // WTF_HashIterators_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/HashFunctions.h ('k') | third_party/WebKit/Source/wtf/HashMap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698