aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/index/suffixarray/suffixarray.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/index/suffixarray/suffixarray.go')
-rw-r--r--libgo/go/index/suffixarray/suffixarray.go11
1 files changed, 2 insertions, 9 deletions
diff --git a/libgo/go/index/suffixarray/suffixarray.go b/libgo/go/index/suffixarray/suffixarray.go
index 079b7d8..82e98d2 100644
--- a/libgo/go/index/suffixarray/suffixarray.go
+++ b/libgo/go/index/suffixarray/suffixarray.go
@@ -22,21 +22,18 @@ import (
"sort"
)
-
// Index implements a suffix array for fast substring search.
type Index struct {
data []byte
sa []int // suffix array for data
}
-
// New creates a new Index for data.
// Index creation time is O(N*log(N)) for N = len(data).
func New(data []byte) *Index {
return &Index{data, qsufsort(data)}
}
-
// Bytes returns the data over which the index was created.
// It must not be modified.
//
@@ -44,12 +41,10 @@ func (x *Index) Bytes() []byte {
return x.data
}
-
func (x *Index) at(i int) []byte {
return x.data[x.sa[i]:]
}
-
// lookupAll returns a slice into the matching region of the index.
// The runtime is O(log(N)*len(s)).
func (x *Index) lookupAll(s []byte) []int {
@@ -61,7 +56,6 @@ func (x *Index) lookupAll(s []byte) []int {
return x.sa[i:j]
}
-
// 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.
@@ -82,7 +76,6 @@ func (x *Index) Lookup(s []byte, n int) (result []int) {
return
}
-
// FindAllIndex returns a sorted list of non-overlapping matches of the
// regular expression r, where a match is a pair of indices specifying
// the matched slice of x.Bytes(). If n < 0, all matches are returned
@@ -115,7 +108,7 @@ func (x *Index) FindAllIndex(r *regexp.Regexp, n int) (result [][]int) {
if len(indices) == 0 {
return
}
- sort.SortInts(indices)
+ sort.Ints(indices)
pairs := make([]int, 2*len(indices))
result = make([][]int, len(indices))
count := 0
@@ -159,7 +152,7 @@ func (x *Index) FindAllIndex(r *regexp.Regexp, n int) (result [][]int) {
if len(indices) == 0 {
return
}
- sort.SortInts(indices)
+ sort.Ints(indices)
result = result[0:0]
prev := 0
for _, i := range indices {