OLD | NEW |
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 Loading... |
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 |
OLD | NEW |