diff options
| author | Robert Griesemer <gri@golang.org> | 2009-11-06 14:24:38 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2009-11-06 14:24:38 -0800 |
| commit | 368f8cbc75c93451fc81a7eacc928e4080d8ed67 (patch) | |
| tree | 0a5ca144b8eb407f99639ec5de1ee2f0df4e747c /src/pkg/container/vector | |
| parent | 8c40900fc28a7dda33a491902c5545b9abb37f58 (diff) | |
| download | go-368f8cbc75c93451fc81a7eacc928e4080d8ed67.tar.xz | |
- fine-tuning of one-line func heuristic (nodes.go)
- enabled for function declarations (not just function literals)
- applied gofmt -w $GOROOT/src
(look for instance at src/pkg/debug/elf/elf.go)
R=r, rsc
CC=go-dev
http://go/go-review/1026006
Diffstat (limited to 'src/pkg/container/vector')
| -rw-r--r-- | src/pkg/container/vector/intvector.go | 32 | ||||
| -rw-r--r-- | src/pkg/container/vector/stringvector.go | 28 | ||||
| -rw-r--r-- | src/pkg/container/vector/vector.go | 28 | ||||
| -rw-r--r-- | src/pkg/container/vector/vector_test.go | 4 |
4 files changed, 23 insertions, 69 deletions
diff --git a/src/pkg/container/vector/intvector.go b/src/pkg/container/vector/intvector.go index 9db2529580..e17d619ad6 100644 --- a/src/pkg/container/vector/intvector.go +++ b/src/pkg/container/vector/intvector.go @@ -21,27 +21,19 @@ func (p *IntVector) Init(len int) *IntVector { // NewIntVector returns an initialized new IntVector with length at least len. -func NewIntVector(len int) *IntVector { - return new(IntVector).Init(len); -} +func NewIntVector(len int) *IntVector { return new(IntVector).Init(len) } // 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. @@ -56,9 +48,7 @@ func (p *IntVector) Data() []int { // 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 @@ -76,15 +66,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. @@ -95,9 +81,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 diff --git a/src/pkg/container/vector/stringvector.go b/src/pkg/container/vector/stringvector.go index 4e54ea85c4..c3f31f046e 100644 --- a/src/pkg/container/vector/stringvector.go +++ b/src/pkg/container/vector/stringvector.go @@ -20,27 +20,19 @@ func (p *StringVector) Init(len int) *StringVector { // NewStringVector returns an initialized new StringVector with length at least len. -func NewStringVector(len int) *StringVector { - return new(StringVector).Init(len); -} +func NewStringVector(len int) *StringVector { return new(StringVector).Init(len) } // At returns the i'th element of the vector. -func (p *StringVector) At(i int) string { - return p.Vector.At(i).(string); -} +func (p *StringVector) At(i int) string { return p.Vector.At(i).(string) } // Set sets the i'th element of the vector to value x. -func (p *StringVector) Set(i int, x string) { - p.a[i] = x; -} +func (p *StringVector) Set(i int, x string) { p.a[i] = x } // Last returns the element in the vector of highest index. -func (p *StringVector) Last() string { - return p.Vector.Last().(string); -} +func (p *StringVector) Last() string { return p.Vector.Last().(string) } // Data returns all the elements as a slice. @@ -75,15 +67,11 @@ func (p *StringVector) Slice(i, j int) *StringVector { // Push appends x to the end of the vector. -func (p *StringVector) Push(x string) { - p.Vector.Push(x); -} +func (p *StringVector) Push(x string) { p.Vector.Push(x) } // Pop deletes and returns the last element of the vector. -func (p *StringVector) Pop() string { - return p.Vector.Pop().(string); -} +func (p *StringVector) Pop() string { return p.Vector.Pop().(string) } // AppendVector appends the entire StringVector x to the end of this vector. @@ -94,9 +82,7 @@ func (p *StringVector) AppendVector(x *StringVector) { // sort.Interface support // Less returns a boolean denoting whether the i'th element is less than the j'th element. -func (p *StringVector) Less(i, j int) bool { - return p.At(i) < p.At(j); -} +func (p *StringVector) Less(i, j int) bool { return p.At(i) < p.At(j) } // Iterate over all elements; driver for range diff --git a/src/pkg/container/vector/vector.go b/src/pkg/container/vector/vector.go index 3746b422a7..ee19997fb7 100644 --- a/src/pkg/container/vector/vector.go +++ b/src/pkg/container/vector/vector.go @@ -79,9 +79,7 @@ func (p *Vector) Init(initial_len int) *Vector { // New returns an initialized new Vector with length at least len. -func New(len int) *Vector { - return new(Vector).Init(len); -} +func New(len int) *Vector { return new(Vector).Init(len) } // Len returns the number of elements in the vector. @@ -95,21 +93,15 @@ func (p *Vector) Len() int { // At returns the i'th element of the vector. -func (p *Vector) At(i int) Element { - return p.a[i]; -} +func (p *Vector) At(i int) Element { return p.a[i] } // Set sets the i'th element of the vector to value x. -func (p *Vector) Set(i int, x Element) { - p.a[i] = x; -} +func (p *Vector) Set(i int, x Element) { p.a[i] = x } // Last returns the element in the vector of highest index. -func (p *Vector) Last() Element { - return p.a[len(p.a)-1]; -} +func (p *Vector) Last() Element { return p.a[len(p.a)-1] } // Data returns all the elements as a slice. @@ -186,9 +178,7 @@ func (p *Vector) Do(f func(elem Element)) { // Convenience wrappers // Push appends x to the end of the vector. -func (p *Vector) Push(x Element) { - p.Insert(len(p.a), x); -} +func (p *Vector) Push(x Element) { p.Insert(len(p.a), x) } // Pop deletes the last element of the vector. @@ -202,9 +192,7 @@ func (p *Vector) Pop() Element { // AppendVector appends the entire Vector x to the end of this vector. -func (p *Vector) AppendVector(x *Vector) { - p.InsertVector(len(p.a), x); -} +func (p *Vector) AppendVector(x *Vector) { p.InsertVector(len(p.a), x) } // Partial sort.Interface support @@ -216,9 +204,7 @@ type LessInterface interface { // Less returns a boolean denoting whether the i'th element is less than the j'th element. -func (p *Vector) Less(i, j int) bool { - return p.a[i].(LessInterface).Less(p.a[j]); -} +func (p *Vector) Less(i, j int) bool { return p.a[i].(LessInterface).Less(p.a[j]) } // Swap exchanges the elements at indexes i and j. diff --git a/src/pkg/container/vector/vector_test.go b/src/pkg/container/vector/vector_test.go index 32a21f3eb6..12a8aa0771 100644 --- a/src/pkg/container/vector/vector_test.go +++ b/src/pkg/container/vector/vector_test.go @@ -48,9 +48,7 @@ func TestNew(t *testing.T) { } -func val(i int) int { - return i*991 - 1234; -} +func val(i int) int { return i*991 - 1234 } func TestAccess(t *testing.T) { |
