GO語言"index/suffixarray"包中"Index.Lookup"類型的用法及代碼示例。
用法:
func(x *Index) Lookup(s []byte, n int)(result []int)
查找返回最多 n 個索引的未排序列表,其中字節字符串 s 出現在索引數據中。如果 n < 0,則返回所有匹配項。如果 s 為空、未找到 s 或 n == 0,則結果為 nil。查找時間為 O(log(N)*len(s) + len(result)),其中 N 是索引數據的大小。
例子:
package main
import (
"fmt"
"index/suffixarray"
)
func main() {
index := suffixarray.New([]byte("banana"))
offsets := index.Lookup([]byte("ana"), -1)
for _, off := range offsets {
fmt.Println(off)
}
}
輸出:
1 3
相關用法
- GO IndexByte用法及代碼示例
- GO IndexFunc用法及代碼示例
- GO IndexAny用法及代碼示例
- GO IndexRune用法及代碼示例
- GO Index用法及代碼示例
- GO Indent用法及代碼示例
- GO Int.Scan用法及代碼示例
- GO Ints用法及代碼示例
- GO Intn用法及代碼示例
- GO Info用法及代碼示例
- GO Int.SetString用法及代碼示例
- GO Inspect用法及代碼示例
- GO IntsAreSorted用法及代碼示例
- GO Itoa用法及代碼示例
- GO IP.IsPrivate用法及代碼示例
- GO IsDigit用法及代碼示例
- GO IP.Equal用法及代碼示例
- GO IsAbs用法及代碼示例
- GO IP.IsLinkLocalMulticast用法及代碼示例
- GO IsGraphic用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Index.Lookup。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。