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

Unified Diff: src/core/SkTDynamicHash.h

Issue 402693003: Replace GrTHash with SkTDynamicHash (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix compiler complaints Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/GrBinHashKey.h » ('j') | src/gpu/GrBinHashKey.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTDynamicHash.h
diff --git a/src/core/SkTDynamicHash.h b/src/core/SkTDynamicHash.h
index 445a45df8580c74bd096a7ec2e74f3bea135c5b9..496dc8d1417e6872d29706f277928eb048a1c9fc 100644
--- a/src/core/SkTDynamicHash.h
+++ b/src/core/SkTDynamicHash.h
@@ -57,6 +57,33 @@ public:
int fCurrentIndex;
};
+ class ConstIter {
+ public:
+ explicit ConstIter(const SkTDynamicHash* hash) : fHash(hash), fCurrentIndex(-1) {
+ SkASSERT(hash);
+ ++(*this);
+ }
+ bool done() const {
+ SkASSERT(fCurrentIndex <= fHash->fCapacity);
+ return fCurrentIndex == fHash->fCapacity;
+ }
+ const T& operator*() const {
+ SkASSERT(!this->done());
+ return *this->current();
+ }
+ void operator++() {
+ do {
+ fCurrentIndex++;
+ } while (!this->done() && (this->current() == Empty() || this->current() == Deleted()));
+ }
+
+ private:
+ const T* current() const { return fHash->fArray[fCurrentIndex]; }
+
+ const SkTDynamicHash* fHash;
+ int fCurrentIndex;
+ };
+
int count() const { return fCount; }
// Return the entry with this key if we have it, otherwise NULL.
@@ -85,13 +112,29 @@ public:
SkASSERT(this->validate());
}
- // Remove the entry with this key. We reqire that an entry with this key is present.
+ // Remove the entry with this key. We require that an entry with this key is present.
void remove(const Key& key) {
SkASSERT(NULL != this->find(key));
this->innerRemove(key);
SkASSERT(this->validate());
}
+ void rewind() {
+ if (NULL != fArray) {
+ sk_bzero(fArray, sizeof(T*)* fCapacity);
+ }
+ fCount = 0;
+ fDeleted = 0;
+ }
+
+ void reset() {
+ fCount = 0;
+ fDeleted = 0;
+ fCapacity = 0;
+ sk_free(fArray);
+ fArray = NULL;
+ }
+
protected:
// These methods are used by tests only.
« no previous file with comments | « no previous file | src/gpu/GrBinHashKey.h » ('j') | src/gpu/GrBinHashKey.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698