mirror of
https://github.com/golang/go
synced 2024-11-25 13:07:57 -07:00
vector: undo changes to autogenerated files
Also, move Do() to vector.go, so that Do() for IntVector and StringVector is autogenerated. The only files edited are Makefile, defs.go, and vector.go. The rest are autogenerated with "make generate". R=r CC=golang-dev, hoisie https://golang.org/cl/1435041
This commit is contained in:
parent
ce9da214b7
commit
eed5bb3bee
@ -44,6 +44,7 @@ generate: vector.go vector_test.go
|
|||||||
| gofmt -r='TestDo -> TestIntDo'\
|
| gofmt -r='TestDo -> TestIntDo'\
|
||||||
| gofmt -r='TestIter -> TestIntIter'\
|
| gofmt -r='TestIter -> TestIntIter'\
|
||||||
| gofmt -r='TestVectorData -> TestIntVectorData'\
|
| gofmt -r='TestVectorData -> TestIntVectorData'\
|
||||||
|
| gofmt -r='interface{} -> int'\
|
||||||
> intvector_test.go\
|
> intvector_test.go\
|
||||||
|
|
||||||
< vector_test.go cat\
|
< vector_test.go cat\
|
||||||
@ -66,4 +67,5 @@ generate: vector.go vector_test.go
|
|||||||
| gofmt -r='TestDo -> TestStrDo'\
|
| gofmt -r='TestDo -> TestStrDo'\
|
||||||
| gofmt -r='TestIter -> TestStrIter'\
|
| gofmt -r='TestIter -> TestStrIter'\
|
||||||
| gofmt -r='TestVectorData -> TestStrVectorData'\
|
| gofmt -r='TestVectorData -> TestStrVectorData'\
|
||||||
|
| gofmt -r='interface{} -> string'\
|
||||||
> stringvector_test.go
|
> stringvector_test.go
|
||||||
|
@ -49,30 +49,3 @@ func (p *IntVector) Less(i, j int) bool { return (*p)[i] < (*p)[j] }
|
|||||||
|
|
||||||
// Less returns a boolean denoting whether the i'th element is less than the j'th element.
|
// 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] }
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -214,3 +214,12 @@ func (p *IntVector) Iter() <-chan int {
|
|||||||
go p.iterate(c)
|
go p.iterate(c)
|
||||||
return 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -279,8 +279,9 @@ func TestIntDo(t *testing.T) {
|
|||||||
a.Set(i, int2IntValue(salt*i))
|
a.Set(i, int2IntValue(salt*i))
|
||||||
}
|
}
|
||||||
count := 0
|
count := 0
|
||||||
a.Do(func(i int) {
|
a.Do(func(e int) {
|
||||||
if i != count*salt {
|
i := intf2IntValue(e)
|
||||||
|
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++
|
||||||
@ -294,8 +295,9 @@ func TestIntDo(t *testing.T) {
|
|||||||
(*b)[i] = int2IntValue(salt * i)
|
(*b)[i] = int2IntValue(salt * i)
|
||||||
}
|
}
|
||||||
count = 0
|
count = 0
|
||||||
b.Do(func(i int) {
|
b.Do(func(e int) {
|
||||||
if i != count*salt {
|
i := intf2IntValue(e)
|
||||||
|
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++
|
||||||
@ -310,8 +312,9 @@ func TestIntDo(t *testing.T) {
|
|||||||
c[i] = int2IntValue(salt * i)
|
c[i] = int2IntValue(salt * i)
|
||||||
}
|
}
|
||||||
count = 0
|
count = 0
|
||||||
c.Do(func(i int) {
|
c.Do(func(e int) {
|
||||||
if i != count*salt {
|
i := intf2IntValue(e)
|
||||||
|
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++
|
||||||
|
@ -214,3 +214,12 @@ func (p *StringVector) Iter() <-chan string {
|
|||||||
go p.iterate(c)
|
go p.iterate(c)
|
||||||
return 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -279,9 +279,10 @@ func TestStrDo(t *testing.T) {
|
|||||||
a.Set(i, int2StrValue(salt*i))
|
a.Set(i, int2StrValue(salt*i))
|
||||||
}
|
}
|
||||||
count := 0
|
count := 0
|
||||||
a.Do(func(s string) {
|
a.Do(func(e string) {
|
||||||
if s != int2StrValue(count*salt) {
|
i := intf2StrValue(e)
|
||||||
t.Error(tname(a), "value at", count, "should be", count*salt, "not", s)
|
if i != int2StrValue(count*salt) {
|
||||||
|
t.Error(tname(a), "value at", count, "should be", count*salt, "not", i)
|
||||||
}
|
}
|
||||||
count++
|
count++
|
||||||
})
|
})
|
||||||
@ -294,9 +295,10 @@ func TestStrDo(t *testing.T) {
|
|||||||
(*b)[i] = int2StrValue(salt * i)
|
(*b)[i] = int2StrValue(salt * i)
|
||||||
}
|
}
|
||||||
count = 0
|
count = 0
|
||||||
b.Do(func(s string) {
|
b.Do(func(e string) {
|
||||||
if s != int2StrValue(count*salt) {
|
i := intf2StrValue(e)
|
||||||
t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", s)
|
if i != int2StrValue(count*salt) {
|
||||||
|
t.Error(tname(b), "b) value at", count, "should be", count*salt, "not", i)
|
||||||
}
|
}
|
||||||
count++
|
count++
|
||||||
})
|
})
|
||||||
@ -310,9 +312,10 @@ func TestStrDo(t *testing.T) {
|
|||||||
c[i] = int2StrValue(salt * i)
|
c[i] = int2StrValue(salt * i)
|
||||||
}
|
}
|
||||||
count = 0
|
count = 0
|
||||||
c.Do(func(s string) {
|
c.Do(func(e string) {
|
||||||
if s != int2StrValue(count*salt) {
|
i := intf2StrValue(e)
|
||||||
t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", s)
|
if i != int2StrValue(count*salt) {
|
||||||
|
t.Error(tname(c), "c) value at", count, "should be", count*salt, "not", i)
|
||||||
}
|
}
|
||||||
count++
|
count++
|
||||||
})
|
})
|
||||||
|
@ -214,3 +214,12 @@ func (p *Vector) Iter() <-chan interface{} {
|
|||||||
go p.iterate(c)
|
go p.iterate(c)
|
||||||
return 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user