XU XUv0.8.8
中文

API

#index/suffixarray

import: #index/suffixarray

counts: 3 fns, 1 methods, 2 types, 0 consts, 0 ifaces

Suffix array lookup / find_all_index.

struct Index

XuAPI
pub struct Index {
    pub data string
    pub sa []int
}

Purpose

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

data string
data
sa []int
field ([]int)

new

XuAPI
pub fn 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
pub fn 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)
n int
count, length, or limit (int)

Returns

[]int — slice result

struct Match

XuAPI
pub struct Match {
    pub from int
    pub to int
}

Purpose

Match is a half-open [from, to) index into the indexed string.

Parameters

from int
field (int)
to int
field (int)

find_all_index

XuAPI
pub fn 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)
n int
count, length, or limit (int)

Returns

[]Match — slice result

(Index) len

XuAPI
pub fn (x Index) len() int

Purpose

Method on `Index`: return the length.

Parameters

x Index
receiver Index (value receiver)

Returns

int — a value of this type