| gofmt -r='TestDo -> TestIntDo'\
| gofmt -r='TestIter -> TestIntIter'\
| gofmt -r='TestVectorData -> TestIntVectorData'\
+ | gofmt -r='interface{} -> int'\
> intvector_test.go\
< vector_test.go cat\
| gofmt -r='TestDo -> TestStrDo'\
| gofmt -r='TestIter -> TestStrIter'\
| gofmt -r='TestVectorData -> TestStrVectorData'\
+ | gofmt -r='interface{} -> string'\
> stringvector_test.go
// Less returns a boolean denoting whether the i'th element is less than the j'th element.
func (p *StringVector) Less(i, j int) bool { return (*p)[i] < (*p)[j] }
-
-
-// Do calls function f for each element of the vector, in order.
-// The behavior of Do is undefined if f changes *p.
-func (p *Vector) Do(f func(elem interface{})) {
- for _, e := range *p {
- f(e)
- }
-}
-
-
-// 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 int)) {
- for _, e := range *p {
- f(e)
- }
-}
-
-
-// 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 string)) {
- for _, e := range *p {
- f(e)
- }
-}
go p.iterate(c)
return c
}
+
+
+// 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 int)) {
+ for _, e := range *p {
+ f(e)
+ }
+}
a.Set(i, int2IntValue(salt*i))
}
count := 0
- a.Do(func(i int) {
- if i != count*salt {
+ a.Do(func(e int) {
+ i := intf2IntValue(e)
+ if i != int2IntValue(count*salt) {
t.Error(tname(a), "value at", count, "should be", count*salt, "not", i)
}
count++
(*b)[i] = int2IntValue(salt * i)
}
count = 0
- b.Do(func(i int) {
- if i != count*salt {
+ b.Do(func(e int) {
+ i := intf2IntValue(e)
+ if i != int2IntValue(count*salt) {
t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", i)
}
count++
c[i] = int2IntValue(salt * i)
}
count = 0
- c.Do(func(i int) {
- if i != count*salt {
+ c.Do(func(e int) {
+ i := intf2IntValue(e)
+ if i != int2IntValue(count*salt) {
t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", i)
}
count++
go p.iterate(c)
return c
}
+
+
+// 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 string)) {
+ for _, e := range *p {
+ f(e)
+ }
+}
a.Set(i, int2StrValue(salt*i))
}
count := 0
- a.Do(func(s string) {
- if s != int2StrValue(count*salt) {
- t.Error(tname(a), "value at", count, "should be", count*salt, "not", s)
+ a.Do(func(e string) {
+ i := intf2StrValue(e)
+ if i != int2StrValue(count*salt) {
+ t.Error(tname(a), "value at", count, "should be", count*salt, "not", i)
}
count++
})
(*b)[i] = int2StrValue(salt * i)
}
count = 0
- b.Do(func(s string) {
- if s != int2StrValue(count*salt) {
- t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", s)
+ b.Do(func(e string) {
+ i := intf2StrValue(e)
+ if i != int2StrValue(count*salt) {
+ t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", i)
}
count++
})
c[i] = int2StrValue(salt * i)
}
count = 0
- c.Do(func(s string) {
- if s != int2StrValue(count*salt) {
- t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", s)
+ c.Do(func(e string) {
+ i := intf2StrValue(e)
+ if i != int2StrValue(count*salt) {
+ t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", i)
}
count++
})
go p.iterate(c)
return c
}
+
+
+// Do calls function f for each element of the vector, in order.
+// The behavior of Do is undefined if f changes *p.
+func (p *Vector) Do(f func(elem interface{})) {
+ for _, e := range *p {
+ f(e)
+ }
+}