aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/container
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-10-11 22:38:42 -0400
committerRuss Cox <rsc@golang.org>2010-10-11 22:38:42 -0400
commite6ecf9765ae8aca669f192aff9a112b6fa10dfcb (patch)
tree6685fba159440534002e007456dd30d0ceae6e5b /src/pkg/container
parentf75129894c1a3ae03716ecedfa757d71a8cab4fe (diff)
downloadgo-e6ecf9765ae8aca669f192aff9a112b6fa10dfcb.tar.xz
exp/iterable: delete
Package iterable has outlived its utility. It is an interesting demonstration, but it encourages people to use iteration over channels where simple iteration over array indices or a linked list would be cheaper, simpler, and have fewer races. R=dsymonds, r CC=golang-dev https://golang.org/cl/2436041
Diffstat (limited to 'src/pkg/container')
-rw-r--r--src/pkg/container/list/list.go13
-rw-r--r--src/pkg/container/list/list_test.go7
2 files changed, 4 insertions, 16 deletions
diff --git a/src/pkg/container/list/list.go b/src/pkg/container/list/list.go
index 16f7a23f1d..55831e8e61 100644
--- a/src/pkg/container/list/list.go
+++ b/src/pkg/container/list/list.go
@@ -180,19 +180,6 @@ func (l *List) MoveToBack(e *Element) {
// Len returns the number of elements in the list.
func (l *List) Len() int { return l.len }
-func (l *List) iterate(c chan<- interface{}) {
- for e := l.front; e != nil; e = e.next {
- c <- e.Value
- }
- close(c)
-}
-
-func (l *List) Iter() <-chan interface{} {
- c := make(chan interface{})
- go l.iterate(c)
- return c
-}
-
// PushBackList inserts each element of ol at the back of the list.
func (l *List) PushBackList(ol *List) {
last := ol.Back()
diff --git a/src/pkg/container/list/list_test.go b/src/pkg/container/list/list_test.go
index bf35c9dd9a..4538a0dcfd 100644
--- a/src/pkg/container/list/list_test.go
+++ b/src/pkg/container/list/list_test.go
@@ -116,8 +116,8 @@ func TestList(t *testing.T) {
// Check standard iteration.
sum := 0
- for e := range l.Iter() {
- if i, ok := e.(int); ok {
+ for e := l.Front(); e != nil; e = e.Next() {
+ if i, ok := e.Value.(int); ok {
sum += i
}
}
@@ -141,7 +141,8 @@ func checkList(t *testing.T, l *List, es []interface{}) {
return
}
i := 0
- for le := range l.Iter() {
+ for e := l.Front(); e != nil; e = e.Next() {
+ le := e.Value.(int)
if le != es[i] {
t.Errorf("elt #%d has value=%v, want %v", i, le, es[i])
}