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

Unified Diff: src/core/SkTDynamicHash.h

Issue 177263005: Counterproposal to 182733007: Add iterator to SkTDynamicHash (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: DEF_TEST Created 6 years, 10 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 | tests/DynamicHashTest.cpp » ('j') | tests/DynamicHashTest.cpp » ('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 8f66c86d907aaaac63df6b4d153fb14af63b6986..80570ae0acb9b4d86f373ad85230da63e571b09e 100644
--- a/src/core/SkTDynamicHash.h
+++ b/src/core/SkTDynamicHash.h
@@ -28,6 +28,33 @@ public:
sk_free(fArray);
}
+ class Iter {
+ public:
+ explicit Iter(SkTDynamicHash* hash) : fHash(hash), fCurrentIndex(-1) {
+ SkASSERT(hash);
+ ++(*this);
+ }
+ bool done() const {
+ SkASSERT(fCurrentIndex <= fHash->fCapacity);
+ return fCurrentIndex == fHash->fCapacity;
+ }
+ T& operator*() const {
+ SkASSERT(!this->done());
+ return *this->current();
+ }
+ void operator++() {
+ do {
+ fCurrentIndex++;
+ } while (!this->done() && (this->current() == Empty() || this->current() == Deleted()));
+ }
+
+ private:
+ T* current() const { return fHash->fArray[fCurrentIndex]; }
+
+ SkTDynamicHash* fHash;
+ int fCurrentIndex;
+ };
+
int count() const { return fCount; }
// Return the entry with this key if we have it, otherwise NULL.
« no previous file with comments | « no previous file | tests/DynamicHashTest.cpp » ('j') | tests/DynamicHashTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698