XU XUv0.16.0

#index/suffixarray

导入方式: #index/suffixarray

公开 API: 3 函数, 1 方法, 2 类型, 0 常量, 0 方法集

后缀数组 lookup / find_all_index。

struct Index

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

用途

承载 data、sa 等属性的结构体。

公开字段

data string
数据
sa []int
字段([]int)

new

XuAPI
pub fn new(data &string) Index

用途

构造该类型的新值。

参数

data &string
数据(只读借用,调用方仍持有原值;类型 &string)

返回值

Index — 该类型的值

lookup

XuAPI
pub fn lookup(x &Index, s &string, n int) []int

用途

在索引或集合中查找匹配的键或项。

参数

x &Index
值(只读借用,调用方仍持有原值;类型 &Index)
s &string
源字符串(只读借用,调用方仍持有原值;类型 &string)
n int
数量、长度或上限(int)

返回值

[]int — 切片结果

struct Match

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

用途

承载 from、to 等属性的结构体。

公开字段

from int
字段(int)
to int
字段(int)

find_all_index

XuAPI
pub fn find_all_index(x &Index, s &string, n int) []Match

用途

执行 find all index 操作。

参数

x &Index
值(只读借用,调用方仍持有原值;类型 &Index)
s &string
源字符串(只读借用,调用方仍持有原值;类型 &string)
n int
数量、长度或上限(int)

返回值

[]Match — 切片结果

(Index) len

XuAPI
pub fn (x Index) len() int

用途

Index 上的操作:返回长度。

参数

x Index
本次调用使用的 Index 实例;按值接收。

返回值

int — 该类型的值