Commit ebb1c8b9 authored by Michael Hoisie's avatar Michael Hoisie Committed by Rob Pike

IntVector.Do now takes an f(int), and StringVector.Do now takes an f(string).

R=r
CC=golang-dev
https://golang.org/cl/1433041
parent 8af4acf5
...@@ -62,7 +62,7 @@ func (p *Vector) Do(f func(elem interface{})) { ...@@ -62,7 +62,7 @@ func (p *Vector) Do(f func(elem interface{})) {
// Do calls function f for each element of the vector, in order. // Do calls function f for each element of the vector, in order.
// The behavior of Do is undefined if f changes *p. // 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 { for _, e := range *p {
f(e) f(e)
} }
...@@ -71,7 +71,7 @@ func (p *IntVector) Do(f func(elem interface{})) { ...@@ -71,7 +71,7 @@ func (p *IntVector) Do(f func(elem interface{})) {
// Do calls function f for each element of the vector, in order. // Do calls function f for each element of the vector, in order.
// The behavior of Do is undefined if f changes *p. // 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 { for _, e := range *p {
f(e) f(e)
} }
......
...@@ -279,9 +279,8 @@ func TestIntDo(t *testing.T) { ...@@ -279,9 +279,8 @@ func TestIntDo(t *testing.T) {
a.Set(i, int2IntValue(salt*i)) a.Set(i, int2IntValue(salt*i))
} }
count := 0 count := 0
a.Do(func(e interface{}) { a.Do(func(i int) {
i := intf2IntValue(e) if i != count*salt {
if i != int2IntValue(count*salt) {
t.Error(tname(a), "value at", count, "should be", count*salt, "not", i) t.Error(tname(a), "value at", count, "should be", count*salt, "not", i)
} }
count++ count++
...@@ -295,9 +294,8 @@ func TestIntDo(t *testing.T) { ...@@ -295,9 +294,8 @@ func TestIntDo(t *testing.T) {
(*b)[i] = int2IntValue(salt * i) (*b)[i] = int2IntValue(salt * i)
} }
count = 0 count = 0
b.Do(func(e interface{}) { b.Do(func(i int) {
i := intf2IntValue(e) if i != count*salt {
if i != int2IntValue(count*salt) {
t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", i) t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", i)
} }
count++ count++
...@@ -312,9 +310,8 @@ func TestIntDo(t *testing.T) { ...@@ -312,9 +310,8 @@ func TestIntDo(t *testing.T) {
c[i] = int2IntValue(salt * i) c[i] = int2IntValue(salt * i)
} }
count = 0 count = 0
c.Do(func(e interface{}) { c.Do(func(i int) {
i := intf2IntValue(e) if i != count*salt {
if i != int2IntValue(count*salt) {
t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", i) t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", i)
} }
count++ count++
......
...@@ -279,10 +279,9 @@ func TestStrDo(t *testing.T) { ...@@ -279,10 +279,9 @@ func TestStrDo(t *testing.T) {
a.Set(i, int2StrValue(salt*i)) a.Set(i, int2StrValue(salt*i))
} }
count := 0 count := 0
a.Do(func(e interface{}) { a.Do(func(s string) {
i := intf2StrValue(e) if s != int2StrValue(count*salt) {
if i != int2StrValue(count*salt) { t.Error(tname(a), "value at", count, "should be", count*salt, "not", s)
t.Error(tname(a), "value at", count, "should be", count*salt, "not", i)
} }
count++ count++
}) })
...@@ -295,10 +294,9 @@ func TestStrDo(t *testing.T) { ...@@ -295,10 +294,9 @@ func TestStrDo(t *testing.T) {
(*b)[i] = int2StrValue(salt * i) (*b)[i] = int2StrValue(salt * i)
} }
count = 0 count = 0
b.Do(func(e interface{}) { b.Do(func(s string) {
i := intf2StrValue(e) if s != int2StrValue(count*salt) {
if i != int2StrValue(count*salt) { t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", s)
t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", i)
} }
count++ count++
}) })
...@@ -312,10 +310,9 @@ func TestStrDo(t *testing.T) { ...@@ -312,10 +310,9 @@ func TestStrDo(t *testing.T) {
c[i] = int2StrValue(salt * i) c[i] = int2StrValue(salt * i)
} }
count = 0 count = 0
c.Do(func(e interface{}) { c.Do(func(s string) {
i := intf2StrValue(e) if s != int2StrValue(count*salt) {
if i != int2StrValue(count*salt) { t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", s)
t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", i)
} }
count++ count++
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment