diff options
author | Michael Hoisie <hoisie@gmail.com> | 2010-05-31 14:55:30 -0700 |
---|---|---|
committer | Michael Hoisie <hoisie@gmail.com> | 2010-05-31 14:55:30 -0700 |
commit | 158eb3b272118b8d06d8f70fe5fdada562c22452 (patch) | |
tree | c39069994a052c869ae85832016aac000e87d18b /src | |
parent | ae5666f978e0d9e77850cc0f38b97100b1ab39e4 (diff) | |
download | golang-158eb3b272118b8d06d8f70fe5fdada562c22452.tar.gz |
IntVector.Do now takes an f(int), and StringVector.Do now takes an f(string).
R=r
CC=golang-dev
http://codereview.appspot.com/1433041
Committer: Rob Pike <r@golang.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/pkg/container/vector/defs.go | 4 | ||||
-rw-r--r-- | src/pkg/container/vector/intvector_test.go | 15 | ||||
-rw-r--r-- | src/pkg/container/vector/stringvector_test.go | 21 |
3 files changed, 17 insertions, 23 deletions
diff --git a/src/pkg/container/vector/defs.go b/src/pkg/container/vector/defs.go index 0607a50c6..7502865c9 100644 --- a/src/pkg/container/vector/defs.go +++ b/src/pkg/container/vector/defs.go @@ -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) } diff --git a/src/pkg/container/vector/intvector_test.go b/src/pkg/container/vector/intvector_test.go index aa536cd16..b8900478b 100644 --- a/src/pkg/container/vector/intvector_test.go +++ b/src/pkg/container/vector/intvector_test.go @@ -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++ diff --git a/src/pkg/container/vector/stringvector_test.go b/src/pkg/container/vector/stringvector_test.go index 2a02a7642..5bc8a626b 100644 --- a/src/pkg/container/vector/stringvector_test.go +++ b/src/pkg/container/vector/stringvector_test.go @@ -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++ }) |