]> Cypherpunks repositories - gostls13.git/commitdiff
IntVector.Do now takes an f(int), and StringVector.Do now takes an f(string).
authorMichael Hoisie <hoisie@gmail.com>
Mon, 31 May 2010 21:55:30 +0000 (14:55 -0700)
committerRob Pike <r@golang.org>
Mon, 31 May 2010 21:55:30 +0000 (14:55 -0700)
R=r
CC=golang-dev
https://golang.org/cl/1433041

src/pkg/container/vector/defs.go
src/pkg/container/vector/intvector_test.go
src/pkg/container/vector/stringvector_test.go

index 0607a50c6de0d38c3eb36c44eb7276b153db2366..7502865c9ccf17e395a49bd03dd89afdd123e682 100644 (file)
@@ -62,7 +62,7 @@ func (p *Vector) Do(f func(elem interface{})) {
 
 // Do calls function f for each element of the vector, in order.
 // The behavior of Do is undefined if f changes *p.
-func (p *IntVector) Do(f func(elem interface{})) {
+func (p *IntVector) Do(f func(elem int)) {
        for _, e := range *p {
                f(e)
        }
@@ -71,7 +71,7 @@ func (p *IntVector) Do(f func(elem interface{})) {
 
 // Do calls function f for each element of the vector, in order.
 // The behavior of Do is undefined if f changes *p.
-func (p *StringVector) Do(f func(elem interface{})) {
+func (p *StringVector) Do(f func(elem string)) {
        for _, e := range *p {
                f(e)
        }
index aa536cd16bcc2b1d26f2ad5cb2ac29c6512db18c..b8900478b250395af75b7dee5b426be6cc7c89db 100644 (file)
@@ -279,9 +279,8 @@ func TestIntDo(t *testing.T) {
                a.Set(i, int2IntValue(salt*i))
        }
        count := 0
-       a.Do(func(e interface{}) {
-               i := intf2IntValue(e)
-               if i != int2IntValue(count*salt) {
+       a.Do(func(i int) {
+               if i != count*salt {
                        t.Error(tname(a), "value at", count, "should be", count*salt, "not", i)
                }
                count++
@@ -295,9 +294,8 @@ func TestIntDo(t *testing.T) {
                (*b)[i] = int2IntValue(salt * i)
        }
        count = 0
-       b.Do(func(e interface{}) {
-               i := intf2IntValue(e)
-               if i != int2IntValue(count*salt) {
+       b.Do(func(i int) {
+               if i != count*salt {
                        t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", i)
                }
                count++
@@ -312,9 +310,8 @@ func TestIntDo(t *testing.T) {
                c[i] = int2IntValue(salt * i)
        }
        count = 0
-       c.Do(func(e interface{}) {
-               i := intf2IntValue(e)
-               if i != int2IntValue(count*salt) {
+       c.Do(func(i int) {
+               if i != count*salt {
                        t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", i)
                }
                count++
index 2a02a76420a7ca53f105bb0582b46c59ed6c6d82..5bc8a626bff316d01b600f13bfe956fecc3331d9 100644 (file)
@@ -279,10 +279,9 @@ func TestStrDo(t *testing.T) {
                a.Set(i, int2StrValue(salt*i))
        }
        count := 0
-       a.Do(func(e interface{}) {
-               i := intf2StrValue(e)
-               if i != int2StrValue(count*salt) {
-                       t.Error(tname(a), "value at", count, "should be", count*salt, "not", i)
+       a.Do(func(s string) {
+               if s != int2StrValue(count*salt) {
+                       t.Error(tname(a), "value at", count, "should be", count*salt, "not", s)
                }
                count++
        })
@@ -295,10 +294,9 @@ func TestStrDo(t *testing.T) {
                (*b)[i] = int2StrValue(salt * i)
        }
        count = 0
-       b.Do(func(e interface{}) {
-               i := intf2StrValue(e)
-               if i != int2StrValue(count*salt) {
-                       t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", i)
+       b.Do(func(s string) {
+               if s != int2StrValue(count*salt) {
+                       t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", s)
                }
                count++
        })
@@ -312,10 +310,9 @@ func TestStrDo(t *testing.T) {
                c[i] = int2StrValue(salt * i)
        }
        count = 0
-       c.Do(func(e interface{}) {
-               i := intf2StrValue(e)
-               if i != int2StrValue(count*salt) {
-                       t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", i)
+       c.Do(func(s string) {
+               if s != int2StrValue(count*salt) {
+                       t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", s)
                }
                count++
        })