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

Side by Side Diff: src/core/SkTHash.h

Issue 1046293002: SkPDF: SkPDFGraphicState Lookup hashtabled (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-04-01 (Wednesday) 16:16:21 EDT Created 5 years, 8 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 | « no previous file | src/pdf/SkPDFCanon.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 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkTHash_DEFINED 8 #ifndef SkTHash_DEFINED
9 #define SkTHash_DEFINED 9 #define SkTHash_DEFINED
10 10
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // Copy an item into the set. 230 // Copy an item into the set.
231 void add(const T& item) { fTable.set(item); } 231 void add(const T& item) { fTable.set(item); }
232 232
233 // Is this item in the set? 233 // Is this item in the set?
234 bool contains(const T& item) const { return SkToBool(this->find(item)); } 234 bool contains(const T& item) const { return SkToBool(this->find(item)); }
235 235
236 // If an item equal to this is in the set, return a pointer to it, otherwise null. 236 // If an item equal to this is in the set, return a pointer to it, otherwise null.
237 // This pointer remains valid until the next call to add(). 237 // This pointer remains valid until the next call to add().
238 const T* find(const T& item) const { return fTable.find(item); } 238 const T* find(const T& item) const { return fTable.find(item); }
239 239
240 // Call fn on every item in the set. You may not mutate anything.
241 template <typename Fn> // f(T), f(const T&)
242 void foreach (Fn&& fn) const {
243 fTable.foreach (fn);
244 }
245
240 private: 246 private:
241 struct Traits { 247 struct Traits {
242 static const T& GetKey(const T& item) { return item; } 248 static const T& GetKey(const T& item) { return item; }
243 static uint32_t Hash(const T& item) { return HashT(item); } 249 static uint32_t Hash(const T& item) { return HashT(item); }
244 }; 250 };
245 SkTHashTable<T, T, Traits> fTable; 251 SkTHashTable<T, T, Traits> fTable;
246 }; 252 };
247 253
248 #endif//SkTHash_DEFINED 254 #endif//SkTHash_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/pdf/SkPDFCanon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698