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
d9c47cd8
Commit
d9c47cd8
authored
Jul 12, 2010
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
container/vector: rename Data() -> Copy()
R=rsc CC=golang-dev
https://golang.org/cl/1814043
parent
1930cd5d
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
21 additions
and
21 deletions
+21
-21
src/pkg/container/vector/Makefile
src/pkg/container/vector/Makefile
+2
-2
src/pkg/container/vector/intvector.go
src/pkg/container/vector/intvector.go
+2
-2
src/pkg/container/vector/intvector_test.go
src/pkg/container/vector/intvector_test.go
+3
-3
src/pkg/container/vector/stringvector.go
src/pkg/container/vector/stringvector.go
+2
-2
src/pkg/container/vector/stringvector_test.go
src/pkg/container/vector/stringvector_test.go
+3
-3
src/pkg/container/vector/vector.go
src/pkg/container/vector/vector.go
+2
-2
src/pkg/container/vector/vector_test.go
src/pkg/container/vector/vector_test.go
+3
-3
src/pkg/exp/iterable/iterable.go
src/pkg/exp/iterable/iterable.go
+3
-3
src/pkg/exp/iterable/iterable_test.go
src/pkg/exp/iterable/iterable_test.go
+1
-1
No files found.
src/pkg/container/vector/Makefile
View file @
d9c47cd8
...
...
@@ -42,7 +42,7 @@ generate: vector.go vector_test.go
| gofmt
-r
=
'make_vector -> make_vectorInt'
\
| gofmt
-r
=
'TestInsertVector -> TestIntInsertVector'
\
| gofmt
-r
=
'TestDo -> TestIntDo'
\
| gofmt
-r
=
'TestVector
Data -> TestIntVectorData
'
\
| gofmt
-r
=
'TestVector
Copy -> TestIntVectorCopy
'
\
| gofmt
-r
=
'interface{} -> int'
\
>
intvector_test.go
\
...
...
@@ -64,6 +64,6 @@ generate: vector.go vector_test.go
| gofmt
-r
=
'make_vector -> make_vectorStr'
\
| gofmt
-r
=
'TestInsertVector -> TestStrInsertVector'
\
| gofmt
-r
=
'TestDo -> TestStrDo'
\
| gofmt
-r
=
'TestVector
Data -> TestStrVectorData
'
\
| gofmt
-r
=
'TestVector
Copy -> TestStrVectorCopy
'
\
| gofmt
-r
=
'interface{} -> string'
\
>
stringvector_test.go
src/pkg/container/vector/intvector.go
View file @
d9c47cd8
...
...
@@ -104,8 +104,8 @@ func (p *IntVector) Set(i int, x int) { (*p)[i] = x }
func
(
p
*
IntVector
)
Last
()
int
{
return
(
*
p
)[
len
(
*
p
)
-
1
]
}
//
Data returns all the elements as a slice
.
func
(
p
*
IntVector
)
Data
()
[]
int
{
//
Copy makes a copy of the vector and returns it
.
func
(
p
*
IntVector
)
Copy
()
IntVector
{
arr
:=
make
(
IntVector
,
len
(
*
p
))
copy
(
arr
,
*
p
)
return
arr
...
...
src/pkg/container/vector/intvector_test.go
View file @
d9c47cd8
...
...
@@ -326,14 +326,14 @@ func TestIntDo(t *testing.T) {
}
func
TestIntVector
Data
(
t
*
testing
.
T
)
{
// verify
Data() returns a slice of a copy, not
a slice of the original vector
func
TestIntVector
Copy
(
t
*
testing
.
T
)
{
// verify
Copy() returns a copy, not simply
a slice of the original vector
const
Len
=
10
var
src
IntVector
for
i
:=
0
;
i
<
Len
;
i
++
{
src
.
Push
(
int2IntValue
(
i
*
i
))
}
dest
:=
src
.
Data
()
dest
:=
src
.
Copy
()
for
i
:=
0
;
i
<
Len
;
i
++
{
src
[
i
]
=
int2IntValue
(
-
1
)
v
:=
elem2IntValue
(
dest
[
i
])
...
...
src/pkg/container/vector/stringvector.go
View file @
d9c47cd8
...
...
@@ -104,8 +104,8 @@ func (p *StringVector) Set(i int, x string) { (*p)[i] = x }
func
(
p
*
StringVector
)
Last
()
string
{
return
(
*
p
)[
len
(
*
p
)
-
1
]
}
//
Data returns all the elements as a slice
.
func
(
p
*
StringVector
)
Data
()
[]
string
{
//
Copy makes a copy of the vector and returns it
.
func
(
p
*
StringVector
)
Copy
()
StringVector
{
arr
:=
make
(
StringVector
,
len
(
*
p
))
copy
(
arr
,
*
p
)
return
arr
...
...
src/pkg/container/vector/stringvector_test.go
View file @
d9c47cd8
...
...
@@ -326,14 +326,14 @@ func TestStrDo(t *testing.T) {
}
func
TestStrVector
Data
(
t
*
testing
.
T
)
{
// verify
Data() returns a slice of a copy, not
a slice of the original vector
func
TestStrVector
Copy
(
t
*
testing
.
T
)
{
// verify
Copy() returns a copy, not simply
a slice of the original vector
const
Len
=
10
var
src
StringVector
for
i
:=
0
;
i
<
Len
;
i
++
{
src
.
Push
(
int2StrValue
(
i
*
i
))
}
dest
:=
src
.
Data
()
dest
:=
src
.
Copy
()
for
i
:=
0
;
i
<
Len
;
i
++
{
src
[
i
]
=
int2StrValue
(
-
1
)
v
:=
elem2StrValue
(
dest
[
i
])
...
...
src/pkg/container/vector/vector.go
View file @
d9c47cd8
...
...
@@ -104,8 +104,8 @@ func (p *Vector) Set(i int, x interface{}) { (*p)[i] = x }
func
(
p
*
Vector
)
Last
()
interface
{}
{
return
(
*
p
)[
len
(
*
p
)
-
1
]
}
//
Data returns all the elements as a slice
.
func
(
p
*
Vector
)
Data
()
[]
interface
{}
{
//
Copy makes a copy of the vector and returns it
.
func
(
p
*
Vector
)
Copy
()
Vector
{
arr
:=
make
(
Vector
,
len
(
*
p
))
copy
(
arr
,
*
p
)
return
arr
...
...
src/pkg/container/vector/vector_test.go
View file @
d9c47cd8
...
...
@@ -326,14 +326,14 @@ func TestDo(t *testing.T) {
}
func
TestVector
Data
(
t
*
testing
.
T
)
{
// verify
Data() returns a slice of a copy, not
a slice of the original vector
func
TestVector
Copy
(
t
*
testing
.
T
)
{
// verify
Copy() returns a copy, not simply
a slice of the original vector
const
Len
=
10
var
src
Vector
for
i
:=
0
;
i
<
Len
;
i
++
{
src
.
Push
(
int2Value
(
i
*
i
))
}
dest
:=
src
.
Data
()
dest
:=
src
.
Copy
()
for
i
:=
0
;
i
<
Len
;
i
++
{
src
[
i
]
=
int2Value
(
-
1
)
v
:=
elem2Value
(
dest
[
i
])
...
...
src/pkg/exp/iterable/iterable.go
View file @
d9c47cd8
...
...
@@ -39,11 +39,11 @@ func Any(iter Iterable, f func(interface{}) bool) bool {
// Data returns a slice containing the elements of iter.
func
Data
(
iter
Iterable
)
[]
interface
{}
{
v
ec
:=
new
(
vector
.
Vector
)
v
ar
v
vector
.
Vector
for
e
:=
range
iter
.
Iter
()
{
v
ec
.
Push
(
e
)
v
.
Push
(
e
)
}
return
v
ec
.
Data
()
return
v
}
// filteredIterable is a struct that implements Iterable with each element
...
...
src/pkg/exp/iterable/iterable_test.go
View file @
d9c47cd8
...
...
@@ -371,7 +371,7 @@ func TestGroupBy(t *testing.T) {
for
x
:=
range
GroupBy
(
elevenToTwenty
,
intkey
{})
.
Iter
()
{
out
.
Push
(
x
.
(
Group
)
.
Key
)
}
assertArraysAreEqual
(
t
,
out
.
Data
()
,
elevenToTwenty
)
assertArraysAreEqual
(
t
,
out
,
elevenToTwenty
)
}
func
TestUnique
(
t
*
testing
.
T
)
{
...
...
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