Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
ebb1c8b9
Commit
ebb1c8b9
authored
May 31, 2010
by
Michael Hoisie
Committed by
Rob Pike
May 31, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
23 deletions
+17
-23
src/pkg/container/vector/defs.go
src/pkg/container/vector/defs.go
+2
-2
src/pkg/container/vector/intvector_test.go
src/pkg/container/vector/intvector_test.go
+6
-9
src/pkg/container/vector/stringvector_test.go
src/pkg/container/vector/stringvector_test.go
+9
-12
No files found.
src/pkg/container/vector/defs.go
View file @
ebb1c8b9
...
...
@@ -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
int
erface
{}
))
{
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
)
}
...
...
src/pkg/container/vector/intvector_test.go
View file @
ebb1c8b9
...
...
@@ -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
++
...
...
src/pkg/container/vector/stringvector_test.go
View file @
ebb1c8b9
...
...
@@ -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
++
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment