contains_int
pub fn contains_int(xs []int, v int) boolPurpose
Concrete helpers: generic `==` is not allowed on Type::Param at check time.
Parameters
xs[]int- slice to operate on ([]int)
vint- value (int)
Returns
bool — true or false
API
#slicesint/string/f64 slice helpers: contains/index/equal/reverse/clone/sort_func and more.
contains_intpub fn contains_int(xs []int, v int) boolConcrete helpers: generic `==` is not allowed on Type::Param at check time.
xs []intv intbool — true or false
index_of_intpub fn index_of_int(xs []int, v int) intIndex of int. Returns -1 if not found.
xs []intv intint — index; -1 if missing
last_index_intpub fn last_index_int(xs &[]int, v int) intLast index int.
xs &[]intv intint — index; -1 if missing
last_index_strpub fn last_index_str(xs &[]string, v string) intLast index str.
xs &[]stringv stringint — index; -1 if missing
sum_intpub fn sum_int(xs []int) intDigest int.
xs []intint — a value of this type
contains_strpub fn contains_str(xs []string, v string) boolContains str.
xs []stringv stringbool — true or false
index_of_strpub fn index_of_str(xs []string, v string) int`slices.Index` — first index of v, -1 when absent. Returns -1 if not found.
xs []stringv stringint — index; -1 if missing
equal_intspub fn equal_ints(a &[]int, b &[]int) bool`slices.Equal` — element-wise equality (read-only borrows).
a &[]intb &[]intbool — true or false
equal_strspub fn equal_strs(a &[]string, b &[]string) boolEqual strs.
a &[]stringb &[]stringbool — true or false
reverse_intspub fn reverse_ints(a &mut []int)`slices.Reverse` — in place, through the exclusive borrow. Every element store is bounds-checked and overwriting an owning (string) element drops its old value first (S1/S3).
a &mut []intreverse_strspub fn reverse_strs(a &mut []string)Reverse strs.
a &mut []stringclone_intspub fn clone_ints(xs &[]int) []int`slices.Clone` — owning copies; the source is only read.
xs &[]int[]int — slice result
clone_strspub fn clone_strs(xs &[]string) []stringClone strs.
xs &[]string[]string — slice result
compare_intspub fn compare_ints(a &[]int, b &[]int) intCompare int slice.
a &[]intb &[]intint — a value of this type
compare_strspub fn compare_strs(a &[]string, b &[]string) intCompare strs.
a &[]stringb &[]stringint — a value of this type
compact_intspub fn compact_ints(xs &[]int) []intCompact int slice.
xs &[]int[]int — slice result
compact_strspub fn compact_strs(xs &[]string) []stringCompact strs.
xs &[]string[]string — slice result
insert_intpub fn insert_int(xs &[]int, i int, v int) []intInsert int.
xs &[]inti intv int[]int — slice result
insert_strpub fn insert_str(xs &[]string, i int, v string) []stringInsert str.
xs &[]stringi intv string[]string — slice result
delete_intspub fn delete_ints(xs &[]int, i int, j int) []intDelete int slice.
xs &[]inti intj int[]int — slice result
delete_strspub fn delete_strs(xs &[]string, i int, j int) []stringDelete strs.
xs &[]stringi intj int[]string — slice result
min_intpub fn min_int(xs &[]int) intMin int. Throws on failure.
xs &[]intint — a value of this type
max_intpub fn max_int(xs &[]int) intMax int. Throws on failure.
xs &[]intint — a value of this type
contains_f64pub fn contains_f64(xs &[]f64, v f64) boolContains f64.
xs &[]f64v f64bool — true or false
index_of_f64pub fn index_of_f64(xs &[]f64, v f64) intIndex of f64. Returns -1 if not found.
xs &[]f64v f64int — index; -1 if missing
equal_f64spub fn equal_f64s(a &[]f64, b &[]f64) boolEqual f64 slice.
a &[]f64b &[]f64bool — true or false
clone_f64spub fn clone_f64s(xs &[]f64) []f64Clone f64 slice.
xs &[]f64[]f64 — slice result
reverse_f64spub fn reverse_f64s(a &mut []f64)Reverse f64 slice.
a &mut []f64min_f64pub fn min_f64(xs &[]f64) f64Min f64. Throws on failure.
xs &[]f64f64 — a value of this type
max_f64pub fn max_f64(xs &[]f64) f64Max f64. Throws on failure.
xs &[]f64f64 — a value of this type
compare_f64spub fn compare_f64s(a &[]f64, b &[]f64) intCompare f64 slice.
a &[]f64b &[]f64int — a value of this type
compact_f64spub fn compact_f64s(xs &[]f64) []f64Compact f64 slice.
xs &[]f64[]f64 — slice result
insert_f64pub fn insert_f64(xs &[]f64, i int, v f64) []f64Insert f64.
xs &[]f64i intv f64[]f64 — slice result
delete_f64spub fn delete_f64s(xs &[]f64, i int, j int) []f64Delete f64 slice.
xs &[]f64i intj int[]f64 — slice result
struct SearchResultpub struct SearchResult {
pub index int
pub found bool
}Public struct `SearchResult`.
index intfound boolbinary_search_intspub fn binary_search_ints(xs &[]int, v int) SearchResultBinary search a sorted slice; returns index and whether it was found.
xs &[]intv intSearchResult — a value of this type
binary_search_strspub fn binary_search_strs(xs &[]string, v string) SearchResultBinary search a sorted slice; returns index and whether it was found.
xs &[]stringv stringSearchResult — a value of this type
binary_search_f64spub fn binary_search_f64s(xs &[]f64, v f64) SearchResultBinary search a sorted slice; returns index and whether it was found.
xs &[]f64v f64SearchResult — a value of this type
replace_intspub fn replace_ints(xs &[]int, i int, j int, add &[]int) []intReplace int slice.
xs &[]inti intj intadd &[]int[]int — slice result
replace_strspub fn replace_strs(xs &[]string, i int, j int, add &[]string) []stringReplace strs.
xs &[]stringi intj intadd &[]string[]string — slice result
concat_intspub fn concat_ints(a &[]int, b &[]int) []intConcat int slice.
a &[]intb &[]int[]int — slice result
repeat_intspub fn repeat_ints(xs &[]int, n int) []intRepeat int slice. Throws on failure.
xs &[]intn int[]int — slice result
repeat_strspub fn repeat_strs(xs &[]string, n int) []stringRepeat strs. Throws on failure.
xs &[]stringn int[]string — slice result
index_func_intspub fn index_func_ints(xs &[]int, f fn(int) bool) intIndex callback int slice.
xs &[]intf fn(int) boolint — index; -1 if missing
contains_func_intspub fn contains_func_ints(xs &[]int, f fn(int) bool) boolContains callback int slice.
xs &[]intf fn(int) boolbool — true or false
index_func_strspub fn index_func_strs(xs &[]string, f fn(string) bool) intIndex callback strs.
xs &[]stringf fn(string) boolint — index; -1 if missing
concat_strspub fn concat_strs(a &[]string, b &[]string) []stringConcat strs.
a &[]stringb &[]string[]string — slice result
sort_ints_funcpub fn sort_ints_func(a &mut []int, less fn(int, int) bool)Concrete SortFunc stand-ins. Generic `sort_func#T` wrapping `sort.slice_func` panics the frozen primer (xuhir index 263) and would fail every oracle fixture that imports this package.
a &mut []intless fn(int, int) boolsort_strs_funcpub fn sort_strs_func(a &mut []string, less fn(string, string) bool)Sort strs callback.
a &mut []stringless fn(string, string) boollast_index_func_intspub fn last_index_func_ints(xs &[]int, f fn(int) bool) intLast index callback int slice.
xs &[]intf fn(int) boolint — index; -1 if missing
last_index_func_strspub fn last_index_func_strs(xs &[]string, f fn(string) bool) intLast index callback strs.
xs &[]stringf fn(string) boolint — index; -1 if missing
min_strpub fn min_str(xs &[]string) stringMin str. Throws on failure.
xs &[]stringstring — result string
max_strpub fn max_str(xs &[]string) stringMax str. Throws on failure.
xs &[]stringstring — result string
is_sorted_intspub fn is_sorted_ints(xs &[]int) boolWhether it is sorted ints.
xs &[]intbool — true or false
is_sorted_strspub fn is_sorted_strs(xs &[]string) boolWhether it is sorted strs.
xs &[]stringbool — true or false
last_index_f64pub fn last_index_f64(xs &[]f64, v f64) intLast index f64.
xs &[]f64v f64int — index; -1 if missing
concat_f64spub fn concat_f64s(a &[]f64, b &[]f64) []f64Concat f64 slice.
a &[]f64b &[]f64[]f64 — slice result
replace_f64spub fn replace_f64s(xs &[]f64, i int, j int, add &[]f64) []f64Replace f64 slice.
xs &[]f64i intj intadd &[]f64[]f64 — slice result
repeat_f64spub fn repeat_f64s(xs &[]f64, n int) []f64Repeat f64 slice. Throws on failure.
xs &[]f64n int[]f64 — slice result
is_sorted_f64spub fn is_sorted_f64s(xs &[]f64) boolWhether it is sorted f64s.
xs &[]f64bool — true or false
contains_func_strspub fn contains_func_strs(xs &[]string, f fn(string) bool) boolContains callback strs.
xs &[]stringf fn(string) boolbool — true or false
compact_func_intspub fn compact_func_ints(xs &[]int, eq fn(int, int) bool) []intCompact callback int slice.
xs &[]inteq fn(int, int) bool[]int — slice result
delete_func_intspub fn delete_func_ints(xs &[]int, f fn(int) bool) []intDelete callback int slice.
xs &[]intf fn(int) bool[]int — slice result