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

Unified Diff: common/data/treapstore/store.go

Issue 2616303002: treapstore: Add Collection.VisitItemsAscend. (Closed)
Patch Set: Created 3 years, 11 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 | common/data/treapstore/store_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/data/treapstore/store.go
diff --git a/common/data/treapstore/store.go b/common/data/treapstore/store.go
index 14599ff9dbe0329c6929989605059ab217edec3f..431881e722db7544ff7289ed4b2d68e95669c429 100644
--- a/common/data/treapstore/store.go
+++ b/common/data/treapstore/store.go
@@ -237,8 +237,19 @@ func (c *Collection) setRoot(root *gtreap.Treap) {
c.root = root
}
-// Iterator returns an iterator over the Store, starting at the supplied pivot
-// item.
+// VisitAscend traverses the Collection ascendingly, invoking visitor for each
+// visited item.
+//
+// If visitor returns false, iteration will stop prematurely.
+//
+// VisitAscend is a more efficient traversal than using an Iterator, and is
+// useful in times when entry-by-entry iteration is not required.
+func (c *Collection) VisitAscend(pivot gtreap.Item, visitor gtreap.ItemVisitor) {
+ c.currentRoot().VisitAscend(pivot, visitor)
+}
+
+// Iterator returns an iterator over the Collection, starting at the supplied
+// pivot item.
func (c *Collection) Iterator(pivot gtreap.Item) *gtreap.Iterator {
root := c.currentRoot()
if root == nil {
« no previous file with comments | « no previous file | common/data/treapstore/store_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698