#maps
Xu 0.16.0 API
导入方式: #maps
公开 API: 4 函数, 22 方法, 2 类型, 0 常量, 0 方法集
库形 StrInt/StrStr。语言 map[K]V 是内建,不经本包。
struct StrInt
pub struct StrInt {
pub keys []string
pub vals []int
pub used []int
pub n int
pub cap int
}
用途
承载 keys、vals、used、n、cap 等属性的结构体。
公开字段
keys []string- 字段([]string)
vals []int- 字段([]int)
used []int- 字段([]int)
n int- 数量、长度或上限
cap int- 字段(int)
struct StrStr
pub struct StrStr {
pub keys []string
pub vals []string
pub used []int
pub n int
pub cap int
}
用途
承载 keys、vals、used、n、cap 等属性的结构体。
公开字段
keys []string- 字段([]string)
vals []string- 字段([]string)
used []int- 字段([]int)
n int- 数量、长度或上限
cap int- 字段(int)
new_str_int
pub fn new_str_int() StrInt
用途
构造 str int。
参数
无需传入参数。
返回值
StrInt — 该类型的值
new_str_str
pub fn new_str_str() StrStr
用途
构造 str str。
参数
无需传入参数。
返回值
StrStr — 该类型的值
($&StrInt) set
pub fn (m $&StrInt) set(k string, v int)
用途
在 $&StrInt 上执行 set 操作。
参数
m $&StrInt- 本次调用使用的
StrInt 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
k string- 键或下标(string)
v int- 值(int)
返回值
不返回值。
($&StrStr) set
pub fn (m $&StrStr) set(k string, v string)
用途
在 $&StrStr 上执行 set 操作。
参数
m $&StrStr- 本次调用使用的
StrStr 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
k string- 键或下标(string)
v string- 值(string)
返回值
不返回值。
(&StrInt) has
pub fn (m &StrInt) has(k string) bool
用途
&StrInt 上的操作:是否具有。
参数
m &StrInt- 本次调用使用的
StrInt 实例;以只读借用传入,调用方仍持有实例。
k string- 键或下标(string)
返回值
bool — 是否成立
(&StrStr) has
pub fn (m &StrStr) has(k string) bool
用途
&StrStr 上的操作:是否具有。
参数
m &StrStr- 本次调用使用的
StrStr 实例;以只读借用传入,调用方仍持有实例。
k string- 键或下标(string)
返回值
bool — 是否成立
(&StrInt) get
pub fn (m &StrInt) get(k string) int
用途
在 &StrInt 上执行 get 操作。失败时抛出错误,调用方需处理或继续传播。
参数
m &StrInt- 本次调用使用的
StrInt 实例;以只读借用传入,调用方仍持有实例。
k string- 键或下标(string)
返回值
int — 该类型的值
(&StrStr) get
pub fn (m &StrStr) get(k string) string
用途
在 &StrStr 上执行 get 操作。失败时抛出错误,调用方需处理或继续传播。
参数
m &StrStr- 本次调用使用的
StrStr 实例;以只读借用传入,调用方仍持有实例。
k string- 键或下标(string)
返回值
string — 结果字符串
($&StrInt) del
pub fn (m $&StrInt) del(k string)
用途
删除指定键或标识对应的数据项。
参数
m $&StrInt- 本次调用使用的
StrInt 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
k string- 键或下标(string)
返回值
不返回值。
($&StrStr) del
pub fn (m $&StrStr) del(k string)
用途
删除指定键或标识对应的数据项。
参数
m $&StrStr- 本次调用使用的
StrStr 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
k string- 键或下标(string)
返回值
不返回值。
($&StrInt) clear
pub fn (m $&StrInt) clear()
用途
清空所有已缓冲或存储的数据项与内部状态。
参数
m $&StrInt- 本次调用使用的
StrInt 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
返回值
不返回值。
($&StrStr) clear
pub fn (m $&StrStr) clear()
用途
清空所有已缓冲或存储的数据项与内部状态。
参数
m $&StrStr- 本次调用使用的
StrStr 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
返回值
不返回值。
(&StrInt) len
pub fn (m &StrInt) len() int
用途
&StrInt 上的操作:返回长度。
参数
m &StrInt- 本次调用使用的
StrInt 实例;以只读借用传入,调用方仍持有实例。
返回值
int — 该类型的值
(&StrStr) len
pub fn (m &StrStr) len() int
用途
&StrStr 上的操作:返回长度。
参数
m &StrStr- 本次调用使用的
StrStr 实例;以只读借用传入,调用方仍持有实例。
返回值
int — 该类型的值
(&StrInt) keys
pub fn (m &StrInt) keys() []string
用途
在 &StrInt 上执行 keys 操作。
参数
m &StrInt- 本次调用使用的
StrInt 实例;以只读借用传入,调用方仍持有实例。
返回值
[]string — 切片结果
(&StrStr) keys
pub fn (m &StrStr) keys() []string
用途
在 &StrStr 上执行 keys 操作。
参数
m &StrStr- 本次调用使用的
StrStr 实例;以只读借用传入,调用方仍持有实例。
返回值
[]string — 切片结果
(&StrInt) values
pub fn (m &StrInt) values() []int
用途
返回当前集合、参数表或映射中所有值的切片。
参数
m &StrInt- 本次调用使用的
StrInt 实例;以只读借用传入,调用方仍持有实例。
返回值
[]int — 切片结果
(&StrStr) values
pub fn (m &StrStr) values() []string
用途
返回当前集合、参数表或映射中所有值的切片。
参数
m &StrStr- 本次调用使用的
StrStr 实例;以只读借用传入,调用方仍持有实例。
返回值
[]string — 切片结果
(&StrInt) clone
pub fn (m &StrInt) clone() StrInt
用途
&StrInt 上的操作:拷贝一份独立的 string。
参数
m &StrInt- 本次调用使用的
StrInt 实例;以只读借用传入,调用方仍持有实例。
返回值
StrInt — 该类型的值
(&StrStr) clone
pub fn (m &StrStr) clone() StrStr
用途
&StrStr 上的操作:拷贝一份独立的 string。
参数
m &StrStr- 本次调用使用的
StrStr 实例;以只读借用传入,调用方仍持有实例。
返回值
StrStr — 该类型的值
(&StrInt) equal
pub fn (m &StrInt) equal(o &StrInt) bool
用途
&StrInt 上的操作:判断两值是否相等。
参数
m &StrInt- 本次调用使用的
StrInt 实例;以只读借用传入,调用方仍持有实例。
o &StrInt- o(只读借用,调用方仍持有原值;类型 &StrInt)
返回值
bool — 是否成立
(&StrStr) equal
pub fn (m &StrStr) equal(o &StrStr) bool
用途
&StrStr 上的操作:判断两值是否相等。
参数
m &StrStr- 本次调用使用的
StrStr 实例;以只读借用传入,调用方仍持有实例。
o &StrStr- o(只读借用,调用方仍持有原值;类型 &StrStr)
返回值
bool — 是否成立
copy_str_int
pub fn copy_str_int(dst $&StrInt, src &StrInt)
用途
执行 copy str int 操作。
参数
dst $&StrInt- 目标(独占借用,可修改原值;类型 $&StrInt)
src &StrInt- 源数据(只读借用,调用方仍持有原值;类型 &StrInt)
返回值
不返回值。
copy_str_str
pub fn copy_str_str(dst $&StrStr, src &StrStr)
用途
执行 copy str str 操作。
参数
dst $&StrStr- 目标(独占借用,可修改原值;类型 $&StrStr)
src &StrStr- 源数据(只读借用,调用方仍持有原值;类型 &StrStr)
返回值
不返回值。
($&StrInt) delete_func
pub fn (m $&StrInt) delete_func(f fn(string, int) bool)
用途
$&StrInt 上的操作:删除回调。
参数
m $&StrInt- 本次调用使用的
StrInt 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
f fn(string, int) bool- 回调函数,签名为
fn(string, int) bool;传入函数值,由本接口在处理过程中调用。
返回值
不返回值。
($&StrStr) delete_func
pub fn (m $&StrStr) delete_func(f fn(string, string) bool)
用途
$&StrStr 上的操作:删除回调。
参数
m $&StrStr- 本次调用使用的
StrStr 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
f fn(string, string) bool- 回调函数,签名为
fn(string, string) bool;传入函数值,由本接口在处理过程中调用。
返回值
不返回值。