summaryrefslogtreecommitdiff
path: root/src/pkg/container/ring/ring.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-02-18 09:50:58 +0100
committerOndřej Surý <ondrej@sury.org>2011-02-18 09:50:58 +0100
commitc072558b90f1bbedc2022b0f30c8b1ac4712538e (patch)
tree67767591619e4bd8111fb05fac185cde94fb7378 /src/pkg/container/ring/ring.go
parent5859517b767c99749a45651c15d4bae5520ebae8 (diff)
downloadgolang-upstream/2011.02.15.tar.gz
Imported Upstream version 2011.02.15upstream/2011.02.15
Diffstat (limited to 'src/pkg/container/ring/ring.go')
-rw-r--r--src/pkg/container/ring/ring.go19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/pkg/container/ring/ring.go b/src/pkg/container/ring/ring.go
index 335afbc3c..5925164e9 100644
--- a/src/pkg/container/ring/ring.go
+++ b/src/pkg/container/ring/ring.go
@@ -138,16 +138,13 @@ func (r *Ring) Len() int {
}
-func (r *Ring) Iter() <-chan interface{} {
- c := make(chan interface{})
- go func() {
- if r != nil {
- c <- r.Value
- for p := r.Next(); p != r; p = p.next {
- c <- p.Value
- }
+// Do calls function f on each element of the ring, in forward order.
+// The behavior of Do is undefined if f changes *r.
+func (r *Ring) Do(f func(interface{})) {
+ if r != nil {
+ f(r.Value)
+ for p := r.Next(); p != r; p = p.next {
+ f(p.Value)
}
- close(c)
- }()
- return c
+ }
}