OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 T* removeAt(int index, uint32_t hash); | 46 T* removeAt(int index, uint32_t hash); |
47 void removeAll(); | 47 void removeAll(); |
48 void deleteAll(); | 48 void deleteAll(); |
49 void unrefAll(); | 49 void unrefAll(); |
50 | 50 |
51 /** | 51 /** |
52 * Return the index for the element, using a linear search. | 52 * Return the index for the element, using a linear search. |
53 */ | 53 */ |
54 int slowFindIndex(T* elem) const { return fSorted.find(elem); } | 54 int slowFindIndex(T* elem) const { return fSorted.find(elem); } |
55 | 55 |
56 #if GR_DEBUG | 56 #if SK_DEBUG |
57 void validate() const; | 57 void validate() const; |
58 bool contains(T*) const; | 58 bool contains(T*) const; |
59 #endif | 59 #endif |
60 | 60 |
61 // testing | 61 // testing |
62 const SkTDArray<T*>& getArray() const { return fSorted; } | 62 const SkTDArray<T*>& getArray() const { return fSorted; } |
63 SkTDArray<T*>& getArray() { return fSorted; } | 63 SkTDArray<T*>& getArray() { return fSorted; } |
64 private: | 64 private: |
65 enum { | 65 enum { |
66 kHashCount = 1 << kHashBits, | 66 kHashCount = 1 << kHashBits, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 fSorted.deleteAll(); | 218 fSorted.deleteAll(); |
219 Gr_bzero(fHash, sizeof(fHash)); | 219 Gr_bzero(fHash, sizeof(fHash)); |
220 } | 220 } |
221 | 221 |
222 template <typename T, typename Key, size_t kHashBits> | 222 template <typename T, typename Key, size_t kHashBits> |
223 void GrTHashTable<T, Key, kHashBits>::unrefAll() { | 223 void GrTHashTable<T, Key, kHashBits>::unrefAll() { |
224 fSorted.unrefAll(); | 224 fSorted.unrefAll(); |
225 Gr_bzero(fHash, sizeof(fHash)); | 225 Gr_bzero(fHash, sizeof(fHash)); |
226 } | 226 } |
227 | 227 |
228 #if GR_DEBUG | 228 #if SK_DEBUG |
229 template <typename T, typename Key, size_t kHashBits> | 229 template <typename T, typename Key, size_t kHashBits> |
230 void GrTHashTable<T, Key, kHashBits>::validate() const { | 230 void GrTHashTable<T, Key, kHashBits>::validate() const { |
231 int count = fSorted.count(); | 231 int count = fSorted.count(); |
232 for (int i = 1; i < count; i++) { | 232 for (int i = 1; i < count; i++) { |
233 SkASSERT(Key::LT(*fSorted[i - 1], *fSorted[i]) || | 233 SkASSERT(Key::LT(*fSorted[i - 1], *fSorted[i]) || |
234 Key::EQ(*fSorted[i - 1], *fSorted[i])); | 234 Key::EQ(*fSorted[i - 1], *fSorted[i])); |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 template <typename T, typename Key, size_t kHashBits> | 238 template <typename T, typename Key, size_t kHashBits> |
239 bool GrTHashTable<T, Key, kHashBits>::contains(T* elem) const { | 239 bool GrTHashTable<T, Key, kHashBits>::contains(T* elem) const { |
240 int index = fSorted.find(elem); | 240 int index = fSorted.find(elem); |
241 return index >= 0; | 241 return index >= 0; |
242 } | 242 } |
243 | 243 |
244 #endif | 244 #endif |
245 | 245 |
246 #endif | 246 #endif |
OLD | NEW |