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

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

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 months 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 12 matching lines...) Expand all
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 #include "wtf/Allocator.h" 29 #include "wtf/Allocator.h"
30 30
31 namespace WTF { 31 namespace WTF {
32 32
33 template <typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstKeysIterator; 33 template <typename HashTableType, typename KeyType, typename MappedType>
34 template <typename HashTableType, typename KeyType, typename MappedType> struct HashTableConstValuesIterator; 34 struct HashTableConstKeysIterator;
35 template <typename HashTableType, typename KeyType, typename MappedType> struct HashTableKeysIterator; 35 template <typename HashTableType, typename KeyType, typename MappedType>
36 template <typename HashTableType, typename KeyType, typename MappedType> struct HashTableValuesIterator; 36 struct HashTableConstValuesIterator;
37 37 template <typename HashTableType, typename KeyType, typename MappedType>
38 template <typename HashTableType, typename KeyType, typename MappedType> 38 struct HashTableKeysIterator;
39 struct HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, Mapped Type>> { 39 template <typename HashTableType, typename KeyType, typename MappedType>
40 STACK_ALLOCATED(); 40 struct HashTableValuesIterator;
41 private: 41
42 typedef KeyValuePair<KeyType, MappedType> ValueType; 42 template <typename HashTableType, typename KeyType, typename MappedType>
43 public: 43 struct HashTableConstIteratorAdapter<HashTableType,
44 typedef HashTableConstKeysIterator<HashTableType, KeyType, MappedType> Keys; 44 KeyValuePair<KeyType, MappedType>> {
45 typedef HashTableConstValuesIterator<HashTableType, KeyType, MappedType> Val ues; 45 STACK_ALLOCATED();
46 46
47 HashTableConstIteratorAdapter() {} 47 private:
48 HashTableConstIteratorAdapter(const typename HashTableType::const_iterator& impl) : m_impl(impl) {} 48 typedef KeyValuePair<KeyType, MappedType> ValueType;
49 49
50 const ValueType* get() const { return (const ValueType*)m_impl.get(); } 50 public:
51 const ValueType& operator*() const { return *get(); } 51 typedef HashTableConstKeysIterator<HashTableType, KeyType, MappedType> Keys;
52 const ValueType* operator->() const { return get(); } 52 typedef HashTableConstValuesIterator<HashTableType, KeyType, MappedType>
53 53 Values;
54 HashTableConstIteratorAdapter& operator++() { ++m_impl; return *this; } 54
55 // postfix ++ intentionally omitted 55 HashTableConstIteratorAdapter() {}
56 56 HashTableConstIteratorAdapter(
57 Keys keys() { return Keys(*this); } 57 const typename HashTableType::const_iterator& impl)
58 Values values() { return Values(*this); } 58 : m_impl(impl) {}
59 59
60 typename HashTableType::const_iterator m_impl; 60 const ValueType* get() const { return (const ValueType*)m_impl.get(); }
61 }; 61 const ValueType& operator*() const { return *get(); }
62 62 const ValueType* operator->() const { return get(); }
63 template <typename HashTableType, typename KeyType, typename MappedType> 63
64 struct HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, MappedType> > { 64 HashTableConstIteratorAdapter& operator++() {
65 STACK_ALLOCATED(); 65 ++m_impl;
66 private: 66 return *this;
67 typedef KeyValuePair<KeyType, MappedType> ValueType; 67 }
68 public: 68 // postfix ++ intentionally omitted
69 typedef HashTableKeysIterator<HashTableType, KeyType, MappedType> Keys; 69
70 typedef HashTableValuesIterator<HashTableType, KeyType, MappedType> Values; 70 Keys keys() { return Keys(*this); }
71 71 Values values() { return Values(*this); }
72 HashTableIteratorAdapter() {} 72
73 HashTableIteratorAdapter(const typename HashTableType::iterator& impl) : m_i mpl(impl) {} 73 typename HashTableType::const_iterator m_impl;
74 74 };
75 ValueType* get() const { return (ValueType*)m_impl.get(); } 75
76 ValueType& operator*() const { return *get(); } 76 template <typename HashTableType, typename KeyType, typename MappedType>
77 ValueType* operator->() const { return get(); } 77 struct HashTableIteratorAdapter<HashTableType,
78 78 KeyValuePair<KeyType, MappedType>> {
79 HashTableIteratorAdapter& operator++() { ++m_impl; return *this; } 79 STACK_ALLOCATED();
80 // postfix ++ intentionally omitted 80
81 81 private:
82 operator HashTableConstIteratorAdapter<HashTableType, ValueType>() 82 typedef KeyValuePair<KeyType, MappedType> ValueType;
83 { 83
84 typename HashTableType::const_iterator i = m_impl; 84 public:
85 return i; 85 typedef HashTableKeysIterator<HashTableType, KeyType, MappedType> Keys;
86 } 86 typedef HashTableValuesIterator<HashTableType, KeyType, MappedType> Values;
87 87
88 Keys keys() { return Keys(*this); } 88 HashTableIteratorAdapter() {}
89 Values values() { return Values(*this); } 89 HashTableIteratorAdapter(const typename HashTableType::iterator& impl)
90 90 : m_impl(impl) {}
91 typename HashTableType::iterator m_impl; 91
92 ValueType* get() const { return (ValueType*)m_impl.get(); }
93 ValueType& operator*() const { return *get(); }
94 ValueType* operator->() const { return get(); }
95
96 HashTableIteratorAdapter& operator++() {
97 ++m_impl;
98 return *this;
99 }
100 // postfix ++ intentionally omitted
101
102 operator HashTableConstIteratorAdapter<HashTableType, ValueType>() {
103 typename HashTableType::const_iterator i = m_impl;
104 return i;
105 }
106
107 Keys keys() { return Keys(*this); }
108 Values values() { return Values(*this); }
109
110 typename HashTableType::iterator m_impl;
92 }; 111 };
93 112
94 template <typename HashTableType, typename KeyType, typename MappedType> 113 template <typename HashTableType, typename KeyType, typename MappedType>
95 struct HashTableConstKeysIterator { 114 struct HashTableConstKeysIterator {
96 STACK_ALLOCATED(); 115 STACK_ALLOCATED();
97 private: 116
98 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, M appedType>> ConstIterator; 117 private:
99 118 typedef HashTableConstIteratorAdapter<HashTableType,
100 public: 119 KeyValuePair<KeyType, MappedType>>
101 HashTableConstKeysIterator(const ConstIterator& impl) : m_impl(impl) {} 120 ConstIterator;
102 121
103 const KeyType* get() const { return &(m_impl.get()->key); } 122 public:
104 const KeyType& operator*() const { return *get(); } 123 HashTableConstKeysIterator(const ConstIterator& impl) : m_impl(impl) {}
105 const KeyType* operator->() const { return get(); } 124
106 125 const KeyType* get() const { return &(m_impl.get()->key); }
107 HashTableConstKeysIterator& operator++() { ++m_impl; return *this; } 126 const KeyType& operator*() const { return *get(); }
108 // postfix ++ intentionally omitted 127 const KeyType* operator->() const { return get(); }
109 128
110 ConstIterator m_impl; 129 HashTableConstKeysIterator& operator++() {
130 ++m_impl;
131 return *this;
132 }
133 // postfix ++ intentionally omitted
134
135 ConstIterator m_impl;
111 }; 136 };
112 137
113 template <typename HashTableType, typename KeyType, typename MappedType> 138 template <typename HashTableType, typename KeyType, typename MappedType>
114 struct HashTableConstValuesIterator { 139 struct HashTableConstValuesIterator {
115 STACK_ALLOCATED(); 140 STACK_ALLOCATED();
116 private: 141
117 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, M appedType>> ConstIterator; 142 private:
118 143 typedef HashTableConstIteratorAdapter<HashTableType,
119 public: 144 KeyValuePair<KeyType, MappedType>>
120 HashTableConstValuesIterator(const ConstIterator& impl) : m_impl(impl) {} 145 ConstIterator;
121 146
122 const MappedType* get() const { return &(m_impl.get()->value); } 147 public:
123 const MappedType& operator*() const { return *get(); } 148 HashTableConstValuesIterator(const ConstIterator& impl) : m_impl(impl) {}
124 const MappedType* operator->() const { return get(); } 149
125 150 const MappedType* get() const { return &(m_impl.get()->value); }
126 HashTableConstValuesIterator& operator++() { ++m_impl; return *this; } 151 const MappedType& operator*() const { return *get(); }
127 // postfix ++ intentionally omitted 152 const MappedType* operator->() const { return get(); }
128 153
129 ConstIterator m_impl; 154 HashTableConstValuesIterator& operator++() {
155 ++m_impl;
156 return *this;
157 }
158 // postfix ++ intentionally omitted
159
160 ConstIterator m_impl;
130 }; 161 };
131 162
132 template <typename HashTableType, typename KeyType, typename MappedType> 163 template <typename HashTableType, typename KeyType, typename MappedType>
133 struct HashTableKeysIterator { 164 struct HashTableKeysIterator {
134 STACK_ALLOCATED(); 165 STACK_ALLOCATED();
135 private: 166
136 typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, Mapped Type>> Iterator; 167 private:
137 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, M appedType>> ConstIterator; 168 typedef HashTableIteratorAdapter<HashTableType,
138 169 KeyValuePair<KeyType, MappedType>>
139 public: 170 Iterator;
140 HashTableKeysIterator(const Iterator& impl) : m_impl(impl) {} 171 typedef HashTableConstIteratorAdapter<HashTableType,
141 172 KeyValuePair<KeyType, MappedType>>
142 KeyType* get() const { return &(m_impl.get()->key); } 173 ConstIterator;
143 KeyType& operator*() const { return *get(); } 174
144 KeyType* operator->() const { return get(); } 175 public:
145 176 HashTableKeysIterator(const Iterator& impl) : m_impl(impl) {}
146 HashTableKeysIterator& operator++() { ++m_impl; return *this; } 177
147 // postfix ++ intentionally omitted 178 KeyType* get() const { return &(m_impl.get()->key); }
148 179 KeyType& operator*() const { return *get(); }
149 operator HashTableConstKeysIterator<HashTableType, KeyType, MappedType>() 180 KeyType* operator->() const { return get(); }
150 { 181
151 ConstIterator i = m_impl; 182 HashTableKeysIterator& operator++() {
152 return i; 183 ++m_impl;
153 } 184 return *this;
154 185 }
155 Iterator m_impl; 186 // postfix ++ intentionally omitted
187
188 operator HashTableConstKeysIterator<HashTableType, KeyType, MappedType>() {
189 ConstIterator i = m_impl;
190 return i;
191 }
192
193 Iterator m_impl;
156 }; 194 };
157 195
158 template <typename HashTableType, typename KeyType, typename MappedType> 196 template <typename HashTableType, typename KeyType, typename MappedType>
159 struct HashTableValuesIterator { 197 struct HashTableValuesIterator {
160 STACK_ALLOCATED(); 198 STACK_ALLOCATED();
161 private: 199
162 typedef HashTableIteratorAdapter<HashTableType, KeyValuePair<KeyType, Mapped Type>> Iterator; 200 private:
163 typedef HashTableConstIteratorAdapter<HashTableType, KeyValuePair<KeyType, M appedType>> ConstIterator; 201 typedef HashTableIteratorAdapter<HashTableType,
164 202 KeyValuePair<KeyType, MappedType>>
165 public: 203 Iterator;
166 HashTableValuesIterator(const Iterator& impl) : m_impl(impl) {} 204 typedef HashTableConstIteratorAdapter<HashTableType,
167 205 KeyValuePair<KeyType, MappedType>>
168 MappedType* get() const { return &(m_impl.get()->value); } 206 ConstIterator;
169 MappedType& operator*() const { return *get(); } 207
170 MappedType* operator->() const { return get(); } 208 public:
171 209 HashTableValuesIterator(const Iterator& impl) : m_impl(impl) {}
172 HashTableValuesIterator& operator++() { ++m_impl; return *this; } 210
173 // postfix ++ intentionally omitted 211 MappedType* get() const { return &(m_impl.get()->value); }
174 212 MappedType& operator*() const { return *get(); }
175 operator HashTableConstValuesIterator<HashTableType, KeyType, MappedType>() 213 MappedType* operator->() const { return get(); }
176 { 214
177 ConstIterator i = m_impl; 215 HashTableValuesIterator& operator++() {
178 return i; 216 ++m_impl;
179 } 217 return *this;
180 218 }
181 Iterator m_impl; 219 // postfix ++ intentionally omitted
182 }; 220
183 221 operator HashTableConstValuesIterator<HashTableType, KeyType, MappedType>() {
184 template <typename T, typename U, typename V> 222 ConstIterator i = m_impl;
185 inline bool operator==(const HashTableConstKeysIterator<T, U, V>& a, const HashT ableConstKeysIterator<T, U, V>& b) 223 return i;
186 { 224 }
187 return a.m_impl == b.m_impl; 225
188 } 226 Iterator m_impl;
189 227 };
190 template <typename T, typename U, typename V> 228
191 inline bool operator!=(const HashTableConstKeysIterator<T, U, V>& a, const HashT ableConstKeysIterator<T, U, V>& b) 229 template <typename T, typename U, typename V>
192 { 230 inline bool operator==(const HashTableConstKeysIterator<T, U, V>& a,
193 return a.m_impl != b.m_impl; 231 const HashTableConstKeysIterator<T, U, V>& b) {
194 } 232 return a.m_impl == b.m_impl;
195 233 }
196 template <typename T, typename U, typename V> 234
197 inline bool operator==(const HashTableConstValuesIterator<T, U, V>& a, const Has hTableConstValuesIterator<T, U, V>& b) 235 template <typename T, typename U, typename V>
198 { 236 inline bool operator!=(const HashTableConstKeysIterator<T, U, V>& a,
199 return a.m_impl == b.m_impl; 237 const HashTableConstKeysIterator<T, U, V>& b) {
200 } 238 return a.m_impl != b.m_impl;
201 239 }
202 template <typename T, typename U, typename V> 240
203 inline bool operator!=(const HashTableConstValuesIterator<T, U, V>& a, const Has hTableConstValuesIterator<T, U, V>& b) 241 template <typename T, typename U, typename V>
204 { 242 inline bool operator==(const HashTableConstValuesIterator<T, U, V>& a,
205 return a.m_impl != b.m_impl; 243 const HashTableConstValuesIterator<T, U, V>& b) {
206 } 244 return a.m_impl == b.m_impl;
207 245 }
208 template <typename T, typename U, typename V> 246
209 inline bool operator==(const HashTableKeysIterator<T, U, V>& a, const HashTableK eysIterator<T, U, V>& b) 247 template <typename T, typename U, typename V>
210 { 248 inline bool operator!=(const HashTableConstValuesIterator<T, U, V>& a,
211 return a.m_impl == b.m_impl; 249 const HashTableConstValuesIterator<T, U, V>& b) {
212 } 250 return a.m_impl != b.m_impl;
213 251 }
214 template <typename T, typename U, typename V> 252
215 inline bool operator!=(const HashTableKeysIterator<T, U, V>& a, const HashTableK eysIterator<T, U, V>& b) 253 template <typename T, typename U, typename V>
216 { 254 inline bool operator==(const HashTableKeysIterator<T, U, V>& a,
217 return a.m_impl != b.m_impl; 255 const HashTableKeysIterator<T, U, V>& b) {
218 } 256 return a.m_impl == b.m_impl;
219 257 }
220 template <typename T, typename U, typename V> 258
221 inline bool operator==(const HashTableValuesIterator<T, U, V>& a, const HashTabl eValuesIterator<T, U, V>& b) 259 template <typename T, typename U, typename V>
222 { 260 inline bool operator!=(const HashTableKeysIterator<T, U, V>& a,
223 return a.m_impl == b.m_impl; 261 const HashTableKeysIterator<T, U, V>& b) {
224 } 262 return a.m_impl != b.m_impl;
225 263 }
226 template <typename T, typename U, typename V> 264
227 inline bool operator!=(const HashTableValuesIterator<T, U, V>& a, const HashTabl eValuesIterator<T, U, V>& b) 265 template <typename T, typename U, typename V>
228 { 266 inline bool operator==(const HashTableValuesIterator<T, U, V>& a,
229 return a.m_impl != b.m_impl; 267 const HashTableValuesIterator<T, U, V>& b) {
230 } 268 return a.m_impl == b.m_impl;
231 269 }
232 } // namespace WTF 270
233 271 template <typename T, typename U, typename V>
234 #endif // WTF_HashIterators_h 272 inline bool operator!=(const HashTableValuesIterator<T, U, V>& a,
273 const HashTableValuesIterator<T, U, V>& b) {
274 return a.m_impl != b.m_impl;
275 }
276
277 } // namespace WTF
278
279 #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