diff options
| author | Robert Griesemer <gri@golang.org> | 2009-11-09 21:13:17 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2009-11-09 21:13:17 -0800 |
| commit | baba292998286e5d9011705a9b4173a2ec99c5e0 (patch) | |
| tree | e5054185cd21c44ee959a8d432b08874a76507fd /src/pkg/container | |
| parent | 1698934194f667c4752bb4dfa8615f146fff5154 (diff) | |
| download | go-baba292998286e5d9011705a9b4173a2ec99c5e0.tar.xz | |
- replaced gofmt expression formatting algorithm with
rsc's algorithm
- applied gofmt -w misc src
- partial CL (remaining files in other CLs)
R=rsc, r
http://go/go-review/1026036
Diffstat (limited to 'src/pkg/container')
| -rw-r--r-- | src/pkg/container/heap/heap.go | 6 | ||||
| -rw-r--r-- | src/pkg/container/ring/ring.go | 2 | ||||
| -rw-r--r-- | src/pkg/container/ring/ring_test.go | 6 | ||||
| -rw-r--r-- | src/pkg/container/vector/vector.go | 20 | ||||
| -rw-r--r-- | src/pkg/container/vector/vector_test.go | 8 |
5 files changed, 21 insertions, 21 deletions
diff --git a/src/pkg/container/heap/heap.go b/src/pkg/container/heap/heap.go index b80805972d..ecaa7481f6 100644 --- a/src/pkg/container/heap/heap.go +++ b/src/pkg/container/heap/heap.go @@ -35,7 +35,7 @@ func Init(h Interface) { sort.Sort(h) } // func Push(h Interface, x interface{}) { h.Push(x); - up(h, h.Len() - 1); + up(h, h.Len()-1); } @@ -66,7 +66,7 @@ func Remove(h Interface, i int) interface{} { func up(h Interface, j int) { for { - i := (j-1)/2; + i := (j - 1) / 2; if i == j || h.Less(i, j) { break } @@ -82,7 +82,7 @@ func down(h Interface, i, n int) { if j >= n { break } - if j1 := j+1; j1 < n && !h.Less(j, j1) { + if j1 := j + 1; j1 < n && !h.Less(j, j1) { j = j1 // = 2*i + 2 } if h.Less(i, j) { diff --git a/src/pkg/container/ring/ring.go b/src/pkg/container/ring/ring.go index a4b631db0b..5fcdfc366f 100644 --- a/src/pkg/container/ring/ring.go +++ b/src/pkg/container/ring/ring.go @@ -119,7 +119,7 @@ func (r *Ring) Unlink(n int) *Ring { if n <= 0 { return nil } - return r.Link(r.Move(n+1)); + return r.Link(r.Move(n + 1)); } diff --git a/src/pkg/container/ring/ring_test.go b/src/pkg/container/ring/ring_test.go index db6fe42c82..b55f438fa2 100644 --- a/src/pkg/container/ring/ring_test.go +++ b/src/pkg/container/ring/ring_test.go @@ -85,8 +85,8 @@ func verify(t *testing.T, r *Ring, N int, sum int) { t.Errorf("r.Move(%d) != r", -N) } for i := 0; i < 10; i++ { - ni := N+i; - mi := ni%N; + ni := N + i; + mi := ni % N; if r.Move(ni) != r.Move(mi) { t.Errorf("r.Move(%d) != r.Move(%d)", ni, mi) } @@ -138,7 +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/vector.go b/src/pkg/container/vector/vector.go index 97c917a7e7..714312be48 100644 --- a/src/pkg/container/vector/vector.go +++ b/src/pkg/container/vector/vector.go @@ -29,13 +29,13 @@ func copy(dst, src []Element) { func expand(a []Element, i, n int) []Element { // make sure we have enough space len0 := len(a); - len1 := len0+n; + len1 := len0 + n; if len1 < cap(a) { // enough space - just expand a = a[0:len1] } else { // not enough space - double capacity - capb := cap(a)*2; + capb := cap(a) * 2; if capb < len1 { // still not enough - use required length capb = len1 @@ -47,7 +47,7 @@ func expand(a []Element, i, n int) []Element { } // make a hole - for j := len0-1; j >= i; j-- { + for j := len0 - 1; j >= i; j-- { a[j+n] = a[j] } return a; @@ -68,12 +68,12 @@ func (p *Vector) Init(initial_len int) *Vector { a = make([]Element, n); } else { // nil out entries - for j := len(a)-1; j >= 0; j-- { + for j := len(a) - 1; j >= 0; j-- { a[j] = nil } } - p.a = a[0 : initial_len]; + p.a = a[0:initial_len]; return p; } @@ -128,7 +128,7 @@ func (p *Vector) Delete(i int) { a := p.a; n := len(a); - copy(a[i : n-1], a[i+1 : n]); + copy(a[i:n-1], a[i+1:n]); a[n-1] = nil; // support GC, nil out entry p.a = a[0 : n-1]; } @@ -138,7 +138,7 @@ func (p *Vector) Delete(i int) { // x such that the 0th element of x appears at index i after insertion. func (p *Vector) InsertVector(i int, x *Vector) { p.a = expand(p.a, i, len(x.a)); - copy(p.a[i : i+len(x.a)], x.a); + copy(p.a[i:i+len(x.a)], x.a); } @@ -146,7 +146,7 @@ func (p *Vector) InsertVector(i int, x *Vector) { func (p *Vector) Cut(i, j int) { a := p.a; n := len(a); - m := n-(j-i); + m := n - (j - i); copy(a[i:m], a[j:n]); for k := m; k < n; k++ { @@ -160,7 +160,7 @@ func (p *Vector) Cut(i, j int) { // Slice returns a new Vector by slicing the old one to extract slice [i:j]. // The elements are copied. The original vector is unchanged. func (p *Vector) Slice(i, j int) *Vector { - s := New(j-i); // will fail in Init() if j < j + s := New(j - i); // will fail in Init() if j < j copy(s.a, p.a[i:j]); return s; } @@ -183,7 +183,7 @@ func (p *Vector) Push(x Element) { p.Insert(len(p.a), x) } // Pop deletes the last element of the vector. func (p *Vector) Pop() Element { - i := len(p.a)-1; + i := len(p.a) - 1; x := p.a[i]; p.a[i] = nil; // support GC, nil out entry p.a = p.a[0:i]; diff --git a/src/pkg/container/vector/vector_test.go b/src/pkg/container/vector/vector_test.go index 4e242601dd..f3c0fdf0c4 100644 --- a/src/pkg/container/vector/vector_test.go +++ b/src/pkg/container/vector/vector_test.go @@ -79,7 +79,7 @@ func TestInsertDeleteClear(t *testing.T) { t.Error("B") } } - for i := n-1; i >= 0; i-- { + for i := n - 1; i >= 0; i-- { if a.Last().(int) != val(0) { t.Error("C") } @@ -146,7 +146,7 @@ func verify_slice(t *testing.T, x *Vector, elt, i, j int) { func verify_pattern(t *testing.T, x *Vector, a, b, c int) { - n := a+b+c; + n := a + b + c; if x.Len() != n { t.Errorf("O) wrong len %d (expected %d)", x.Len(), n) } @@ -194,7 +194,7 @@ func TestSorting(t *testing.T) { const n = 100; a := NewIntVector(n); - for i := n-1; i >= 0; i-- { + for i := n - 1; i >= 0; i-- { a.Set(i, n-1-i) } if sort.IsSorted(a) { @@ -202,7 +202,7 @@ func TestSorting(t *testing.T) { } b := NewStringVector(n); - for i := n-1; i >= 0; i-- { + for i := n - 1; i >= 0; i-- { b.Set(i, fmt.Sprint(n-1-i)) } if sort.IsSorted(b) { |
