diff options
author | Robert Griesemer <gri@golang.org> | 2010-09-22 11:03:57 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2010-09-22 11:03:57 -0700 |
commit | 0a3f2313dcf40c9d5b860e2b9c27648f895a49e0 (patch) | |
tree | 8983842db64a528ac887ebe3393de2b0671776cb | |
parent | 96adbeaa4f587a879bcf6cff09b8e04cbe626fe8 (diff) | |
download | go-0a3f2313dcf40c9d5b860e2b9c27648f895a49e0.tar.gz |
suffixarray: cleanup per suggestion from Roger Peppe
R=rsc
CC=golang-dev
http://codereview.appspot.com/2213045
-rw-r--r-- | src/pkg/index/suffixarray/suffixarray.go | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/pkg/index/suffixarray/suffixarray.go b/src/pkg/index/suffixarray/suffixarray.go index acc9a785f..0a1747296 100644 --- a/src/pkg/index/suffixarray/suffixarray.go +++ b/src/pkg/index/suffixarray/suffixarray.go @@ -43,9 +43,9 @@ func New(data []byte) *Index { for i, _ := range sa { sa[i] = i } - x := &index{data, sa} - sort.Sort(x) - return (*Index)(x) + x := &Index{data, sa} + sort.Sort((*index)(x)) + return x } @@ -75,7 +75,7 @@ func (x *Index) search(s []byte) int { // Lookup returns an unsorted list of at most n indices where the byte string s // occurs in the indexed data. If n < 0, all occurrences are returned. // The result is nil if s is empty, s is not found, or n == 0. -// Lookup time is O((log(N) + len(res))*len(s)) where N is the +// Lookup time is O((log(N) + len(result))*len(s)) where N is the // size of the indexed data. // func (x *Index) Lookup(s []byte, n int) []int { @@ -102,14 +102,8 @@ func (x *Index) Lookup(s []byte, n int) []int { } -// index is like Index; it is only used to hide the sort.Interface methods -type index struct { - data []byte - sa []int -} - - -// index implements sort.Interface +// index is used to hide the sort.Interface +type index Index func (x *index) Len() int { return len(x.sa) } func (x *index) Less(i, j int) bool { return bytes.Compare(x.at(i), x.at(j)) < 0 } |