In-memory suffix array aligned with `index/suffixarray` New + Lookup. Construction is Manber–Myers doubling with introsort on rank pairs ( is O(N) SA-IS). Lookup is binary search then a linear scan of the match run.
Parameters
datastring
data
sa[]int
field ([]int)
new
XuAPI
pubfn new(data &string) Index
Purpose
Construct a new value of this type.
Parameters
data&string
data (borrowed; caller keeps it; type &string)
Returns
Index — a value of this type
lookup
XuAPI
pubfn lookup(x &Index, s &string, n int) []int
Purpose
Lookup.
Parameters
x&Index
value (borrowed; caller keeps it; type &Index)
s&string
source string (borrowed; caller keeps it; type &string)
nint
count, length, or limit (int)
Returns
[]int — slice result
struct Match
XuAPI
pubstruct Match {
pub from intpub to int
}
Purpose
Match is a half-open [from, to) index into the indexed string.
Parameters
fromint
field (int)
toint
field (int)
find_all_index
XuAPI
pubfn find_all_index(x &Index, s &string, n int) []Match
Purpose
FindAllIndex aligned with `Index.FindAllIndex`.
Parameters
x&Index
value (borrowed; caller keeps it; type &Index)
s&string
source string (borrowed; caller keeps it; type &string)