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

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

Issue 1058553002: Add SkTHashSet::find() (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: const 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 | tests/HashTest.cpp » ('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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // Clear the set. 224 // Clear the set.
225 void reset() { fTable.reset(); } 225 void reset() { fTable.reset(); }
226 226
227 // How many items are in the set? 227 // How many items are in the set?
228 int count() const { return fTable.count(); } 228 int count() const { return fTable.count(); }
229 229
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(fTable.find(item)); } 234 bool contains(const T& item) const { return SkToBool(this->find(item)); }
235
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().
238 const T* find(const T& item) const { return fTable.find(item); }
235 239
236 private: 240 private:
237 struct Traits { 241 struct Traits {
238 static const T& GetKey(const T& item) { return item; } 242 static const T& GetKey(const T& item) { return item; }
239 static uint32_t Hash(const T& item) { return HashT(item); } 243 static uint32_t Hash(const T& item) { return HashT(item); }
240 }; 244 };
241 SkTHashTable<T, T, Traits> fTable; 245 SkTHashTable<T, T, Traits> fTable;
242 }; 246 };
243 247
244 #endif//SkTHash_DEFINED 248 #endif//SkTHash_DEFINED
OLDNEW
« no previous file with comments | « no previous file | tests/HashTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698