OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 SkTDynamicHash_DEFINED | 8 #ifndef SkTDynamicHash_DEFINED |
9 #define SkTDynamicHash_DEFINED | 9 #define SkTDynamicHash_DEFINED |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 | 121 |
122 void rewind() { | 122 void rewind() { |
123 if (fArray) { | 123 if (fArray) { |
124 sk_bzero(fArray, sizeof(T*)* fCapacity); | 124 sk_bzero(fArray, sizeof(T*)* fCapacity); |
125 } | 125 } |
126 fCount = 0; | 126 fCount = 0; |
127 fDeleted = 0; | 127 fDeleted = 0; |
128 } | 128 } |
129 | 129 |
130 void reset() { | 130 void reset() { |
131 fCount = 0; | 131 fCount = 0; |
132 fDeleted = 0; | 132 fDeleted = 0; |
133 fCapacity = 0; | 133 fCapacity = 0; |
134 sk_free(fArray); | 134 sk_free(fArray); |
135 fArray = nullptr; | 135 fArray = nullptr; |
136 } | 136 } |
137 | 137 |
138 protected: | 138 protected: |
139 // These methods are used by tests only. | 139 // These methods are used by tests only. |
140 | 140 |
141 int capacity() const { return fCapacity; } | 141 int capacity() const { return fCapacity; } |
142 | 142 |
143 // How many collisions do we go through before finding where this entry shou
ld be inserted? | 143 // How many collisions do we go through before finding where this entry shou
ld be inserted? |
144 int countCollisions(const Key& key) const { | 144 int countCollisions(const Key& key) const { |
145 int index = this->firstIndex(key); | 145 int index = this->firstIndex(key); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 static const Key& GetKey(const T& t) { return Traits::GetKey(t); } | 280 static const Key& GetKey(const T& t) { return Traits::GetKey(t); } |
281 static uint32_t Hash(const Key& key) { return Traits::Hash(key); } | 281 static uint32_t Hash(const Key& key) { return Traits::Hash(key); } |
282 | 282 |
283 int fCount; // Number of non Empty(), non Deleted() entries in fArray. | 283 int fCount; // Number of non Empty(), non Deleted() entries in fArray. |
284 int fDeleted; // Number of Deleted() entries in fArray. | 284 int fDeleted; // Number of Deleted() entries in fArray. |
285 int fCapacity; // Number of entries in fArray. Always a power of 2. | 285 int fCapacity; // Number of entries in fArray. Always a power of 2. |
286 T** fArray; | 286 T** fArray; |
287 }; | 287 }; |
288 | 288 |
289 #endif | 289 #endif |
OLD | NEW |