summaryrefslogtreecommitdiff
path: root/src/pkg/container
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/container')
-rw-r--r--src/pkg/container/heap/heap.go4
-rw-r--r--src/pkg/container/heap/heap_test.go8
-rwxr-xr-xsrc/pkg/container/list/list.go24
-rw-r--r--src/pkg/container/ring/ring_test.go4
-rw-r--r--src/pkg/container/vector/intvector.go32
-rw-r--r--src/pkg/container/vector/stringvector.go28
-rw-r--r--src/pkg/container/vector/vector.go28
-rw-r--r--src/pkg/container/vector/vector_test.go4
8 files changed, 33 insertions, 99 deletions
diff --git a/src/pkg/container/heap/heap.go b/src/pkg/container/heap/heap.go
index f78e3b3a5..100dcad05 100644
--- a/src/pkg/container/heap/heap.go
+++ b/src/pkg/container/heap/heap.go
@@ -27,9 +27,7 @@ type Interface interface {
// and may be called whenever the heap invariants may have been invalidated.
// Its complexity is O(n*log(n)) where n = h.Len().
//
-func Init(h Interface) {
- sort.Sort(h);
-}
+func Init(h Interface) { sort.Sort(h) }
// Push pushes the element x onto the heap. The complexity is
diff --git a/src/pkg/container/heap/heap_test.go b/src/pkg/container/heap/heap_test.go
index 99722f2e9..2375906b9 100644
--- a/src/pkg/container/heap/heap_test.go
+++ b/src/pkg/container/heap/heap_test.go
@@ -43,14 +43,10 @@ func (h *myHeap) verify(t *testing.T, i int) {
}
-func (h *myHeap) Push(x interface{}) {
- h.IntVector.Push(x.(int));
-}
+func (h *myHeap) Push(x interface{}) { h.IntVector.Push(x.(int)) }
-func (h *myHeap) Pop() interface{} {
- return h.IntVector.Pop();
-}
+func (h *myHeap) Pop() interface{} { return h.IntVector.Pop() }
func TestInit(t *testing.T) {
diff --git a/src/pkg/container/list/list.go b/src/pkg/container/list/list.go
index acd34c417..b1f12080f 100755
--- a/src/pkg/container/list/list.go
+++ b/src/pkg/container/list/list.go
@@ -19,14 +19,10 @@ type Element struct {
}
// Next returns the next list element or nil.
-func (e *Element) Next() *Element {
- return e.next;
-}
+func (e *Element) Next() *Element { return e.next }
// Prev returns the previous list element or nil.
-func (e *Element) Prev() *Element {
- return e.prev;
-}
+func (e *Element) Prev() *Element { return e.prev }
// List represents a doubly linked list.
type List struct {
@@ -45,19 +41,13 @@ func (l *List) Init() *List {
}
// New returns an initialized list.
-func New() *List {
- return new(List).Init();
-}
+func New() *List { return new(List).Init() }
// Front returns the first element in the list.
-func (l *List) Front() *Element {
- return l.front;
-}
+func (l *List) Front() *Element { return l.front }
// Back returns the last element in the list.
-func (l *List) Back() *Element {
- return l.back;
-}
+func (l *List) Back() *Element { return l.back }
// Remove removes the element from the list.
func (l *List) Remove(e *Element) {
@@ -187,9 +177,7 @@ func (l *List) MoveToBack(e *Element) {
}
// Len returns the number of elements in the list.
-func (l *List) Len() int {
- return l.len;
-}
+func (l *List) Len() int { return l.len }
func (l *List) iterate(c chan<- interface{}) {
for e := l.front; e != nil; e = e.next {
diff --git a/src/pkg/container/ring/ring_test.go b/src/pkg/container/ring/ring_test.go
index 0dc3a71d1..7032cdfcf 100644
--- a/src/pkg/container/ring/ring_test.go
+++ b/src/pkg/container/ring/ring_test.go
@@ -138,9 +138,7 @@ func sum(r *Ring) int {
}
-func sumN(n int) int {
- return (n*n + n)/2;
-}
+func sumN(n int) int { return (n*n + n)/2 }
func TestNew(t *testing.T) {
diff --git a/src/pkg/container/vector/intvector.go b/src/pkg/container/vector/intvector.go
index 9db252958..e17d619ad 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 4e54ea85c..c3f31f046 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 3746b422a..ee19997fb 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 32a21f3eb..12a8aa077 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) {