summaryrefslogtreecommitdiff
path: root/src/lib/container/vector.go
diff options
context:
space:
mode:
authorDavid Symonds <dsymonds@golang.org>2009-04-05 22:40:40 -0700
committerDavid Symonds <dsymonds@golang.org>2009-04-05 22:40:40 -0700
commit459936e9bf8e03e26b5de91356588dc2020cca7f (patch)
treef2092936c6bc81b30463c75166f9151ff4b947b8 /src/lib/container/vector.go
parenteaa9156ff73f91f666aa6df5cdd85269a556f05b (diff)
downloadgolang-459936e9bf8e03e26b5de91356588dc2020cca7f.tar.gz
Add an Iterable package with handy functions like All, Any and Map.
Add a Data method to vector.Vector. R=r,rsc APPROVED=rsc DELTA=173 (170 added, 0 deleted, 3 changed) OCL=26980 CL=27098
Diffstat (limited to 'src/lib/container/vector.go')
-rw-r--r--src/lib/container/vector.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/container/vector.go b/src/lib/container/vector.go
index 07c7d3df0..392e5e596 100644
--- a/src/lib/container/vector.go
+++ b/src/lib/container/vector.go
@@ -107,6 +107,16 @@ func (p *Vector) Last() Element {
}
+// Data returns all the elements as a slice.
+func (p *Vector) Data() []Element {
+ arr := make([]Element, p.Len());
+ for i, v := range p.a {
+ arr[i] = v
+ }
+ return arr
+}
+
+
// Insert inserts into the vector an element of value x before
// the current element at index i.
func (p *Vector) Insert(i int, x Element) {