diff options
| author | Robert Griesemer <gri@golang.org> | 2009-11-09 12:07:39 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2009-11-09 12:07:39 -0800 |
| commit | 40621d5c0d3f9fc222089967ab1aec44e94b5f78 (patch) | |
| tree | aab097e5a2fcb1b6df8781a044ebfcb1b10a18e5 /src/pkg/container/vector | |
| parent | 18ccbc69f8ba71a396acba50ecfe5a591f687c78 (diff) | |
| download | go-40621d5c0d3f9fc222089967ab1aec44e94b5f78.tar.xz | |
remove semis after statements in one-statement statement lists
R=rsc, r
http://go/go-review/1025029
Diffstat (limited to 'src/pkg/container/vector')
| -rw-r--r-- | src/pkg/container/vector/intvector.go | 10 | ||||
| -rw-r--r-- | src/pkg/container/vector/stringvector.go | 12 | ||||
| -rw-r--r-- | src/pkg/container/vector/vector.go | 22 | ||||
| -rw-r--r-- | src/pkg/container/vector/vector_test.go | 72 |
4 files changed, 58 insertions, 58 deletions
diff --git a/src/pkg/container/vector/intvector.go b/src/pkg/container/vector/intvector.go index e17d619ad6..75f794f79a 100644 --- a/src/pkg/container/vector/intvector.go +++ b/src/pkg/container/vector/intvector.go @@ -40,7 +40,7 @@ func (p *IntVector) Last() int { return p.Vector.Last().(int) } func (p *IntVector) Data() []int { arr := make([]int, p.Len()); for i, v := range p.a { - arr[i] = v.(int); + arr[i] = v.(int) } return arr; } @@ -54,14 +54,14 @@ func (p *IntVector) Insert(i int, x int) { p.Vector.Insert(i, x) } // InsertVector inserts into the vector the contents of the Vector // x such that the 0th element of x appears at index i after insertion. func (p *IntVector) InsertVector(i int, x *IntVector) { - p.Vector.InsertVector(i, &x.Vector); + p.Vector.InsertVector(i, &x.Vector) } // Slice returns a new IntVector by slicing the old one to extract slice [i:j]. // The elements are copied. The original vector is unchanged. func (p *IntVector) Slice(i, j int) *IntVector { - return &IntVector{*p.Vector.Slice(i, j)}; + return &IntVector{*p.Vector.Slice(i, j)} } @@ -75,7 +75,7 @@ func (p *IntVector) Pop() int { return p.Vector.Pop().(int) } // AppendVector appends the entire IntVector x to the end of this vector. func (p *IntVector) AppendVector(x *IntVector) { - p.Vector.InsertVector(len(p.a), &x.Vector); + p.Vector.InsertVector(len(p.a), &x.Vector) } @@ -87,7 +87,7 @@ func (p *IntVector) Less(i, j int) bool { return p.At(i) < p.At(j) } // Iterate over all elements; driver for range func (p *IntVector) iterate(c chan<- int) { for _, v := range p.a { - c <- v.(int); + c <- v.(int) } close(c); } diff --git a/src/pkg/container/vector/stringvector.go b/src/pkg/container/vector/stringvector.go index c3f31f046e..0178f6be2e 100644 --- a/src/pkg/container/vector/stringvector.go +++ b/src/pkg/container/vector/stringvector.go @@ -39,7 +39,7 @@ func (p *StringVector) Last() string { return p.Vector.Last().(string) } func (p *StringVector) Data() []string { arr := make([]string, p.Len()); for i, v := range p.a { - arr[i] = v.(string); + arr[i] = v.(string) } return arr; } @@ -48,21 +48,21 @@ func (p *StringVector) Data() []string { // Insert inserts into the vector an element of value x before // the current element at index i. func (p *StringVector) Insert(i int, x string) { - p.Vector.Insert(i, x); + p.Vector.Insert(i, x) } // InsertVector inserts into the vector the contents of the Vector // x such that the 0th element of x appears at index i after insertion. func (p *StringVector) InsertVector(i int, x *StringVector) { - p.Vector.InsertVector(i, &x.Vector); + p.Vector.InsertVector(i, &x.Vector) } // Slice returns a new StringVector by slicing the old one to extract slice [i:j]. // The elements are copied. The original vector is unchanged. func (p *StringVector) Slice(i, j int) *StringVector { - return &StringVector{*p.Vector.Slice(i, j)}; + return &StringVector{*p.Vector.Slice(i, j)} } @@ -76,7 +76,7 @@ func (p *StringVector) Pop() string { return p.Vector.Pop().(string) } // AppendVector appends the entire StringVector x to the end of this vector. func (p *StringVector) AppendVector(x *StringVector) { - p.Vector.InsertVector(len(p.a), &x.Vector); + p.Vector.InsertVector(len(p.a), &x.Vector) } @@ -88,7 +88,7 @@ func (p *StringVector) Less(i, j int) bool { return p.At(i) < p.At(j) } // Iterate over all elements; driver for range func (p *StringVector) iterate(c chan<- string) { for _, v := range p.a { - c <- v.(string); + c <- v.(string) } close(c); } diff --git a/src/pkg/container/vector/vector.go b/src/pkg/container/vector/vector.go index ee19997fb7..97c917a7e7 100644 --- a/src/pkg/container/vector/vector.go +++ b/src/pkg/container/vector/vector.go @@ -20,7 +20,7 @@ type Vector struct { func copy(dst, src []Element) { for i := 0; i < len(src); i++ { - dst[i] = src[i]; + dst[i] = src[i] } } @@ -32,13 +32,13 @@ func expand(a []Element, i, n int) []Element { len1 := len0+n; if len1 < cap(a) { // enough space - just expand - a = a[0:len1]; + a = a[0:len1] } else { // not enough space - double capacity capb := cap(a)*2; if capb < len1 { // still not enough - use required length - capb = len1; + capb = len1 } // capb >= len1 b := make([]Element, len1, capb); @@ -48,7 +48,7 @@ func expand(a []Element, i, n int) []Element { // make a hole for j := len0-1; j >= i; j-- { - a[j+n] = a[j]; + a[j+n] = a[j] } return a; } @@ -63,13 +63,13 @@ func (p *Vector) Init(initial_len int) *Vector { if cap(a) == 0 || cap(a) < initial_len { n := 8; // initial capacity if initial_len > n { - n = initial_len; + n = initial_len } a = make([]Element, n); } else { // nil out entries for j := len(a)-1; j >= 0; j-- { - a[j] = nil; + a[j] = nil } } @@ -86,7 +86,7 @@ func New(len int) *Vector { return new(Vector).Init(len) } // Len is 0 if p == nil. func (p *Vector) Len() int { if p == nil { - return 0; + return 0 } return len(p.a); } @@ -108,7 +108,7 @@ func (p *Vector) Last() Element { return p.a[len(p.a)-1] } func (p *Vector) Data() []Element { arr := make([]Element, p.Len()); for i, v := range p.a { - arr[i] = v; + arr[i] = v } return arr; } @@ -150,7 +150,7 @@ func (p *Vector) Cut(i, j int) { copy(a[i:m], a[j:n]); for k := m; k < n; k++ { - a[k] = nil; // support GC, nil out entries + a[k] = nil // support GC, nil out entries } p.a = a[0:m]; @@ -170,7 +170,7 @@ func (p *Vector) Slice(i, j int) *Vector { // The function should not change the indexing of the vector underfoot. func (p *Vector) Do(f func(elem Element)) { for i := 0; i < len(p.a); i++ { - f(p.a[i]); // not too safe if f changes the Vector + f(p.a[i]) // not too safe if f changes the Vector } } @@ -217,7 +217,7 @@ func (p *Vector) Swap(i, j int) { // Iterate over all elements; driver for range func (p *Vector) iterate(c chan<- Element) { for _, v := range p.a { - c <- v; + c <- v } close(c); } diff --git a/src/pkg/container/vector/vector_test.go b/src/pkg/container/vector/vector_test.go index 12a8aa0771..4e242601dd 100644 --- a/src/pkg/container/vector/vector_test.go +++ b/src/pkg/container/vector/vector_test.go @@ -12,11 +12,11 @@ import "fmt" func TestZeroLen(t *testing.T) { var a *Vector; if a.Len() != 0 { - t.Errorf("A) expected 0, got %d", a.Len()); + t.Errorf("A) expected 0, got %d", a.Len()) } a = New(0); if a.Len() != 0 { - t.Errorf("B) expected 0, got %d", a.Len()); + t.Errorf("B) expected 0, got %d", a.Len()) } } @@ -24,26 +24,26 @@ func TestZeroLen(t *testing.T) { func TestInit(t *testing.T) { var a Vector; if a.Init(0).Len() != 0 { - t.Error("A"); + t.Error("A") } if a.Init(1).Len() != 1 { - t.Error("B"); + t.Error("B") } if a.Init(10).Len() != 10 { - t.Error("C"); + t.Error("C") } } func TestNew(t *testing.T) { if New(0).Len() != 0 { - t.Error("A"); + t.Error("A") } if New(1).Len() != 1 { - t.Error("B"); + t.Error("B") } if New(10).Len() != 10 { - t.Error("C"); + t.Error("C") } } @@ -56,11 +56,11 @@ func TestAccess(t *testing.T) { var a Vector; a.Init(n); for i := 0; i < n; i++ { - a.Set(i, val(i)); + a.Set(i, val(i)) } for i := 0; i < n; i++ { if a.At(i).(int) != val(i) { - t.Error(i); + t.Error(i) } } } @@ -72,41 +72,41 @@ func TestInsertDeleteClear(t *testing.T) { for i := 0; i < n; i++ { if a.Len() != i { - t.Errorf("A) wrong len %d (expected %d)", a.Len(), i); + t.Errorf("A) wrong len %d (expected %d)", a.Len(), i) } a.Insert(0, val(i)); if a.Last().(int) != val(0) { - t.Error("B"); + t.Error("B") } } for i := n-1; i >= 0; i-- { if a.Last().(int) != val(0) { - t.Error("C"); + t.Error("C") } if a.At(0).(int) != val(i) { - t.Error("D"); + t.Error("D") } a.Delete(0); if a.Len() != i { - t.Errorf("E) wrong len %d (expected %d)", a.Len(), i); + t.Errorf("E) wrong len %d (expected %d)", a.Len(), i) } } if a.Len() != 0 { - t.Errorf("F) wrong len %d (expected 0)", a.Len()); + t.Errorf("F) wrong len %d (expected 0)", a.Len()) } for i := 0; i < n; i++ { a.Push(val(i)); if a.Len() != i+1 { - t.Errorf("G) wrong len %d (expected %d)", a.Len(), i+1); + t.Errorf("G) wrong len %d (expected %d)", a.Len(), i+1) } if a.Last().(int) != val(i) { - t.Error("H"); + t.Error("H") } } a.Init(0); if a.Len() != 0 { - t.Errorf("I wrong len %d (expected 0)", a.Len()); + t.Errorf("I wrong len %d (expected 0)", a.Len()) } const m = 5; @@ -116,15 +116,15 @@ func TestInsertDeleteClear(t *testing.T) { x := val(i); a.Push(x); if a.Pop().(int) != x { - t.Error("J"); + t.Error("J") } if a.Len() != j+1 { - t.Errorf("K) wrong len %d (expected %d)", a.Len(), j+1); + t.Errorf("K) wrong len %d (expected %d)", a.Len(), j+1) } } } if a.Len() != m { - t.Errorf("L) wrong len %d (expected %d)", a.Len(), m); + t.Errorf("L) wrong len %d (expected %d)", a.Len(), m) } } @@ -132,14 +132,14 @@ func TestInsertDeleteClear(t *testing.T) { func verify_slice(t *testing.T, x *Vector, elt, i, j int) { for k := i; k < j; k++ { if x.At(k).(int) != elt { - t.Errorf("M) wrong [%d] element %d (expected %d)", k, x.At(k).(int), elt); + t.Errorf("M) wrong [%d] element %d (expected %d)", k, x.At(k).(int), elt) } } s := x.Slice(i, j); for k, n := 0, j-i; k < n; k++ { if s.At(k).(int) != elt { - t.Errorf("N) wrong [%d] element %d (expected %d)", k, x.At(k).(int), elt); + t.Errorf("N) wrong [%d] element %d (expected %d)", k, x.At(k).(int), elt) } } } @@ -148,7 +148,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; if x.Len() != n { - t.Errorf("O) wrong len %d (expected %d)", x.Len(), n); + t.Errorf("O) wrong len %d (expected %d)", x.Len(), n) } verify_slice(t, x, 0, 0, a); verify_slice(t, x, 1, a, a+b); @@ -159,7 +159,7 @@ func verify_pattern(t *testing.T, x *Vector, a, b, c int) { func make_vector(elt, len int) *Vector { x := New(len); for i := 0; i < len; i++ { - x.Set(i, elt); + x.Set(i, elt) } return x; } @@ -195,18 +195,18 @@ func TestSorting(t *testing.T) { a := NewIntVector(n); for i := n-1; i >= 0; i-- { - a.Set(i, n-1-i); + a.Set(i, n-1-i) } if sort.IsSorted(a) { - t.Error("int vector not sorted"); + t.Error("int vector not sorted") } b := NewStringVector(n); for i := n-1; i >= 0; i-- { - b.Set(i, fmt.Sprint(n-1-i)); + b.Set(i, fmt.Sprint(n-1-i)) } if sort.IsSorted(b) { - t.Error("string vector not sorted"); + t.Error("string vector not sorted") } } @@ -216,18 +216,18 @@ func TestDo(t *testing.T) { const salt = 17; a := NewIntVector(n); for i := 0; i < n; i++ { - a.Set(i, salt*i); + a.Set(i, salt*i) } count := 0; a.Do(func(e Element) { i := e.(int); if i != count*salt { - t.Error("value at", count, "should be", count*salt, "not", i); + t.Error("value at", count, "should be", count*salt, "not", i) } count++; }); if count != n { - t.Error("should visit", n, "values; did visit", count); + t.Error("should visit", n, "values; did visit", count) } } @@ -236,16 +236,16 @@ func TestIter(t *testing.T) { const Len = 100; x := New(Len); for i := 0; i < Len; i++ { - x.Set(i, i*i); + x.Set(i, i*i) } i := 0; for v := range x.Iter() { if v.(int) != i*i { - t.Error("Iter expected", i*i, "got", v.(int)); + t.Error("Iter expected", i*i, "got", v.(int)) } i++; } if i != Len { - t.Error("Iter stopped at", i, "not", Len); + t.Error("Iter stopped at", i, "not", Len) } } |
