contains_int
pub fn contains_int(xs []int, v int) bool用途
包含int。
参数
xs[]int- 要处理的切片([]int)
vint- 值(int)
返回
bool — 是否成立
API
#slicesint/string/f64 切片:contains/index/equal/reverse/clone/sort_func 等。
contains_intpub fn contains_int(xs []int, v int) bool包含int。
xs []intv intbool — 是否成立
index_of_intpub fn index_of_int(xs []int, v int) int下标ofint。未找到返回 -1。
xs []intv intint — 下标;未找到为 -1
last_index_intpub fn last_index_int(xs &[]int, v int) intlast下标int。
xs &[]intv intint — 下标;未找到为 -1
last_index_strpub fn last_index_str(xs &[]string, v string) intlast下标str。
xs &[]stringv stringint — 下标;未找到为 -1
sum_intpub fn sum_int(xs []int) int摘要int。
xs []intint — 该类型的值
contains_strpub fn contains_str(xs []string, v string) bool包含str。
xs []stringv stringbool — 是否成立
index_of_strpub fn index_of_str(xs []string, v string) int下标ofstr。未找到返回 -1。
xs []stringv stringint — 下标;未找到为 -1
equal_intspub fn equal_ints(a &[]int, b &[]int) bool相等int 切片。
a &[]intb &[]intbool — 是否成立
equal_strspub fn equal_strs(a &[]string, b &[]string) bool相等strs。
a &[]stringb &[]stringbool — 是否成立
reverse_intspub fn reverse_ints(a &mut []int)逆序int 切片。
a &mut []intreverse_strspub fn reverse_strs(a &mut []string)逆序strs。
a &mut []stringclone_intspub fn clone_ints(xs &[]int) []int拷贝int 切片。
xs &[]int[]int — 切片结果
clone_strspub fn clone_strs(xs &[]string) []string拷贝strs。
xs &[]string[]string — 切片结果
compare_intspub fn compare_ints(a &[]int, b &[]int) int比较int 切片。
a &[]intb &[]intint — 该类型的值
compare_strspub fn compare_strs(a &[]string, b &[]string) int比较strs。
a &[]stringb &[]stringint — 该类型的值
compact_intspub fn compact_ints(xs &[]int) []int压成一行int 切片。
xs &[]int[]int — 切片结果
compact_strspub fn compact_strs(xs &[]string) []string压成一行strs。
xs &[]string[]string — 切片结果
insert_intpub fn insert_int(xs &[]int, i int, v int) []int插入int。
xs &[]inti intv int[]int — 切片结果
insert_strpub fn insert_str(xs &[]string, i int, v string) []string插入str。
xs &[]stringi intv string[]string — 切片结果
delete_intspub fn delete_ints(xs &[]int, i int, j int) []int删除int 切片。
xs &[]inti intj int[]int — 切片结果
delete_strspub fn delete_strs(xs &[]string, i int, j int) []string删除strs。
xs &[]stringi intj int[]string — 切片结果
min_intpub fn min_int(xs &[]int) int最小int。失败时 throw。
xs &[]intint — 该类型的值
max_intpub fn max_int(xs &[]int) int最大int。失败时 throw。
xs &[]intint — 该类型的值
contains_f64pub fn contains_f64(xs &[]f64, v f64) bool包含f64。
xs &[]f64v f64bool — 是否成立
index_of_f64pub fn index_of_f64(xs &[]f64, v f64) int下标off64。未找到返回 -1。
xs &[]f64v f64int — 下标;未找到为 -1
equal_f64spub fn equal_f64s(a &[]f64, b &[]f64) bool相等f64 切片。
a &[]f64b &[]f64bool — 是否成立
clone_f64spub fn clone_f64s(xs &[]f64) []f64拷贝f64 切片。
xs &[]f64[]f64 — 切片结果
reverse_f64spub fn reverse_f64s(a &mut []f64)逆序f64 切片。
a &mut []f64min_f64pub fn min_f64(xs &[]f64) f64最小f64。失败时 throw。
xs &[]f64f64 — 该类型的值
max_f64pub fn max_f64(xs &[]f64) f64最大f64。失败时 throw。
xs &[]f64f64 — 该类型的值
compare_f64spub fn compare_f64s(a &[]f64, b &[]f64) int比较f64 切片。
a &[]f64b &[]f64int — 该类型的值
compact_f64spub fn compact_f64s(xs &[]f64) []f64压成一行f64 切片。
xs &[]f64[]f64 — 切片结果
insert_f64pub fn insert_f64(xs &[]f64, i int, v f64) []f64插入f64。
xs &[]f64i intv f64[]f64 — 切片结果
delete_f64spub fn delete_f64s(xs &[]f64, i int, j int) []f64删除f64 切片。
xs &[]f64i intj int[]f64 — 切片结果
struct SearchResultpub struct SearchResult {
pub index int
pub found bool
}公开结构体 `SearchResult`。
index intfound boolbinary_search_intspub fn binary_search_ints(xs &[]int, v int) SearchResult在已排序切片中二分查找,返回下标与是否命中。
xs &[]intv intSearchResult — 该类型的值
binary_search_strspub fn binary_search_strs(xs &[]string, v string) SearchResult在已排序切片中二分查找,返回下标与是否命中。
xs &[]stringv stringSearchResult — 该类型的值
binary_search_f64spub fn binary_search_f64s(xs &[]f64, v f64) SearchResult在已排序切片中二分查找,返回下标与是否命中。
xs &[]f64v f64SearchResult — 该类型的值
replace_intspub fn replace_ints(xs &[]int, i int, j int, add &[]int) []int替换int 切片。
xs &[]inti intj intadd &[]int[]int — 切片结果
replace_strspub fn replace_strs(xs &[]string, i int, j int, add &[]string) []string替换strs。
xs &[]stringi intj intadd &[]string[]string — 切片结果
concat_intspub fn concat_ints(a &[]int, b &[]int) []intconcatint 切片。
a &[]intb &[]int[]int — 切片结果
repeat_intspub fn repeat_ints(xs &[]int, n int) []int重复int 切片。失败时 throw。
xs &[]intn int[]int — 切片结果
repeat_strspub fn repeat_strs(xs &[]string, n int) []string重复strs。失败时 throw。
xs &[]stringn int[]string — 切片结果
index_func_intspub fn index_func_ints(xs &[]int, f fn(int) bool) int下标回调int 切片。
xs &[]intf fn(int) boolint — 下标;未找到为 -1
contains_func_intspub fn contains_func_ints(xs &[]int, f fn(int) bool) bool包含回调int 切片。
xs &[]intf fn(int) boolbool — 是否成立
index_func_strspub fn index_func_strs(xs &[]string, f fn(string) bool) int下标回调strs。
xs &[]stringf fn(string) boolint — 下标;未找到为 -1
concat_strspub fn concat_strs(a &[]string, b &[]string) []stringconcatstrs。
a &[]stringb &[]string[]string — 切片结果
sort_ints_funcpub fn sort_ints_func(a &mut []int, less fn(int, int) bool)排序int 切片回调。
a &mut []intless fn(int, int) boolsort_strs_funcpub fn sort_strs_func(a &mut []string, less fn(string, string) bool)排序strs回调。
a &mut []stringless fn(string, string) boollast_index_func_intspub fn last_index_func_ints(xs &[]int, f fn(int) bool) intlast下标回调int 切片。
xs &[]intf fn(int) boolint — 下标;未找到为 -1
last_index_func_strspub fn last_index_func_strs(xs &[]string, f fn(string) bool) intlast下标回调strs。
xs &[]stringf fn(string) boolint — 下标;未找到为 -1
min_strpub fn min_str(xs &[]string) string最小str。失败时 throw。
xs &[]stringstring — 结果字符串
max_strpub fn max_str(xs &[]string) string最大str。失败时 throw。
xs &[]stringstring — 结果字符串
is_sorted_intspub fn is_sorted_ints(xs &[]int) bool判断是否 sorted ints。
xs &[]intbool — 是否成立
is_sorted_strspub fn is_sorted_strs(xs &[]string) bool判断是否 sorted strs。
xs &[]stringbool — 是否成立
last_index_f64pub fn last_index_f64(xs &[]f64, v f64) intlast下标f64。
xs &[]f64v f64int — 下标;未找到为 -1
concat_f64spub fn concat_f64s(a &[]f64, b &[]f64) []f64concatf64 切片。
a &[]f64b &[]f64[]f64 — 切片结果
replace_f64spub fn replace_f64s(xs &[]f64, i int, j int, add &[]f64) []f64替换f64 切片。
xs &[]f64i intj intadd &[]f64[]f64 — 切片结果
repeat_f64spub fn repeat_f64s(xs &[]f64, n int) []f64重复f64 切片。失败时 throw。
xs &[]f64n int[]f64 — 切片结果
is_sorted_f64spub fn is_sorted_f64s(xs &[]f64) bool判断是否 sorted f64s。
xs &[]f64bool — 是否成立
contains_func_strspub fn contains_func_strs(xs &[]string, f fn(string) bool) bool包含回调strs。
xs &[]stringf fn(string) boolbool — 是否成立
compact_func_intspub fn compact_func_ints(xs &[]int, eq fn(int, int) bool) []int压成一行回调int 切片。
xs &[]inteq fn(int, int) bool[]int — 切片结果
delete_func_intspub fn delete_func_ints(xs &[]int, f fn(int) bool) []int删除回调int 切片。
xs &[]intf fn(int) bool[]int — 切片结果