summaryrefslogtreecommitdiff
path: root/src/lib/container/array/intarray.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2008-11-19 14:05:21 -0800
committerRobert Griesemer <gri@golang.org>2008-11-19 14:05:21 -0800
commit934e17dce1c4c4b0da5ac761efe2d426ebe42d78 (patch)
tree9203a2aac970a991620b395ad0e4801dcc208a50 /src/lib/container/array/intarray.go
parentf47e8ff5ad1e002c648d7af538b542912bd46bc1 (diff)
downloadgolang-934e17dce1c4c4b0da5ac761efe2d426ebe42d78.tar.gz
- array lib (essentially vector, more complete)
- TODO replace vector R=r DELTA=314 (313 added, 0 deleted, 1 changed) OCL=19592 CL=19609
Diffstat (limited to 'src/lib/container/array/intarray.go')
-rw-r--r--src/lib/container/array/intarray.go64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/lib/container/array/intarray.go b/src/lib/container/array/intarray.go
new file mode 100644
index 000000000..eb7e83907
--- /dev/null
+++ b/src/lib/container/array/intarray.go
@@ -0,0 +1,64 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package array
+
+import "array"
+
+export type IntArray struct {
+ // TODO do not export field
+ array.Array;
+}
+
+
+func (p *IntArray) Init(len int) *IntArray {
+ p.Array.Init(len);
+ return p;
+}
+
+
+export func NewIntArray(len int) *IntArray {
+ return new(IntArray).Init(len)
+}
+
+
+func (p *IntArray) At(i int) int {
+ return p.Array.At(i).(int)
+}
+
+
+func (p *IntArray) Set(i int, x int) {
+ p.Array.Set(i, x)
+}
+
+
+func (p *IntArray) Last() int {
+ return p.Array.Last().(int)
+}
+
+
+func (p *IntArray) Insert(i int, x int) {
+ p.Array.Insert(i, x)
+}
+
+
+func (p *IntArray) Remove(i int) int {
+ return p.Array.Remove(i).(int)
+}
+
+
+func (p *IntArray) Push(x int) {
+ p.Array.Push(x)
+}
+
+
+func (p *IntArray) Pop() int {
+ return p.Array.Pop().(int)
+}
+
+
+// SortInterface support
+func (p *IntArray) Less(i, j int) bool {
+ return p.At(i) < p.At(j)
+}