diff options
Diffstat (limited to 'src/pkg/container/vector/intvector.go')
-rw-r--r-- | src/pkg/container/vector/intvector.go | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/pkg/container/vector/intvector.go b/src/pkg/container/vector/intvector.go index 43f8ff808..1ec4b85a9 100644 --- a/src/pkg/container/vector/intvector.go +++ b/src/pkg/container/vector/intvector.go @@ -7,7 +7,7 @@ package vector // IntVector is a specialization of Vector that hides the wrapping of Elements around ints. type IntVector struct { - Vector; + Vector } @@ -17,40 +17,40 @@ type IntVector struct { // Resize adds 0 elements. The capacity parameter is ignored unless the // new length or capacity is longer that the current capacity. func (p *IntVector) Resize(length, capacity int) *IntVector { - i := p.Len(); - p.Vector.Resize(length, capacity); + i := p.Len() + p.Vector.Resize(length, capacity) for a := p.a; i < len(a); i++ { a[i] = 0 } - return p; + return p } // At returns the i'th element of the vector. -func (p *IntVector) At(i int) int { return p.Vector.At(i).(int) } +func (p *IntVector) At(i int) int { return p.Vector.At(i).(int) } // Set sets the i'th element of the vector to value x. -func (p *IntVector) Set(i int, x int) { p.a[i] = x } +func (p *IntVector) Set(i int, x int) { p.a[i] = x } // Last returns the element in the vector of highest index. -func (p *IntVector) Last() int { return p.Vector.Last().(int) } +func (p *IntVector) Last() int { return p.Vector.Last().(int) } // Data returns all the elements as a slice. func (p *IntVector) Data() []int { - arr := make([]int, p.Len()); + arr := make([]int, p.Len()) for i, v := range p.a { arr[i] = v.(int) } - return arr; + return arr } // Insert inserts into the vector an element of value x before // the current element at index i. -func (p *IntVector) Insert(i int, x int) { p.Vector.Insert(i, x) } +func (p *IntVector) Insert(i int, x int) { p.Vector.Insert(i, x) } // InsertVector inserts into the vector the contents of the Vector @@ -68,11 +68,11 @@ func (p *IntVector) Slice(i, j int) *IntVector { // Push appends x to the end of the vector. -func (p *IntVector) Push(x int) { p.Vector.Push(x) } +func (p *IntVector) Push(x int) { p.Vector.Push(x) } // Pop deletes and returns the last element of the vector. -func (p *IntVector) Pop() int { return p.Vector.Pop().(int) } +func (p *IntVector) Pop() int { return p.Vector.Pop().(int) } // AppendVector appends the entire IntVector x to the end of this vector. @@ -83,7 +83,7 @@ func (p *IntVector) AppendVector(x *IntVector) { // sort.Interface support // Less returns a boolean denoting whether the i'th element is less than the j'th element. -func (p *IntVector) Less(i, j int) bool { return p.At(i) < p.At(j) } +func (p *IntVector) Less(i, j int) bool { return p.At(i) < p.At(j) } // Iterate over all elements; driver for range @@ -91,13 +91,13 @@ func (p *IntVector) iterate(c chan<- int) { for _, v := range p.a { c <- v.(int) } - close(c); + close(c) } // Channel iterator for range. func (p *IntVector) Iter() <-chan int { - c := make(chan int); - go p.iterate(c); - return c; + c := make(chan int) + go p.iterate(c) + return c } |