lib.arrays
Sfall array library functions Converted from headers/sfall/lib.arrays.h @author phobos2077
Functions
Section titled “Functions”map_contains_key
Section titled “map_contains_key”function map_contains_key<K, V>(arrayMap: SfallMap<K, V>, key: K): boolean
Check if key exists in map array
get_empty_array_index
Section titled “get_empty_array_index”function get_empty_array_index<T>(array: SfallList<T>): number
Returns first index of zero value in a list array
array_push
Section titled “array_push”function array_push<T>(array: SfallList<T>, item: T): SfallList<T>
Push item to end of list array, returns the array
array_pop
Section titled “array_pop”function array_pop<T>(array: SfallList<T>): T
Remove and return last item from list array
array_keys
Section titled “array_keys”function array_keys<K, V>(array: SfallMap<K, V>): SfallList<K>
Returns a temp list of keys from a given array
array_values
Section titled “array_values”function array_values<K, V>(array: SfallMap<K, V>): SfallList<V>
Returns a temp list of values from a given array
array_fixed
Section titled “array_fixed”function array_fixed<T>(array: SfallList<T>): SfallList<T>
Makes array permanent and returns it
array_slice
Section titled “array_slice”function array_slice<T>(array: SfallList<T>, index: number, count: number): SfallList<T>
Returns a slice of list array as new temp array
array_cut
Section titled “array_cut”function array_cut<T>(array: SfallList<T>, index: number, count: number): SfallList<T>
Remove a slice from list array and return it
copy_array
Section titled “copy_array”function copy_array<T>(src: SfallList<T>, srcPos: number, dest: SfallList<T>, dstPos: number, size: number): void
Copy a slice of one array into another (will not resize)
clone_array
Section titled “clone_array”function clone_array<K, V>(array: SfallMap<K, V>): SfallMap<K, V>
Create a shallow copy of array as new temp array
arrays_equal
Section titled “arrays_equal”function arrays_equal<T>(arr1: SfallList<T>, arr2: SfallList<T>): boolean
Compare two arrays for equality
array_max
Section titled “array_max”function array_max(arr: SfallList<number>): number
Returns maximum element in array
array_min
Section titled “array_min”function array_min(arr: SfallList<number>): number
Returns minimum element in array
array_sum
Section titled “array_sum”function array_sum(arr: SfallList<number>): number
Returns sum of array elements
array_random_value
Section titled “array_random_value”function array_random_value<T>(arr: SfallList<T>): T
Returns a random value from list array
add_array_set
Section titled “add_array_set”function add_array_set<T>(array: SfallList<T>, item: T): boolean
Add item to set (list array with unique values). Returns true if added.
remove_array_set
Section titled “remove_array_set”function remove_array_set<T>(array: SfallList<T>, item: T): boolean
Remove item from set. Returns true if removed.
array_fill
Section titled “array_fill”function array_fill<T>(arr: SfallList<T>, pos: number, count: number, value: T): SfallList<T>
Fill array with value
array_append
Section titled “array_append”function array_append<T>(arr1: SfallList<T>, arr2: SfallList<T>): SfallList<T>
Append all items from arr2 to arr1
array_concat
Section titled “array_concat”function array_concat<T>(arr1: SfallList<T>, arr2: SfallList<T>): SfallList<T>
Concat arrays into new temp array
load_create_array
Section titled “load_create_array”function load_create_array(name: string, size: number): SfallList<any>
Load saved array, create if doesn’t exist
load_create_array_map
Section titled “load_create_array_map”function load_create_array_map(name: string): SfallMap<any, any>
Load saved array map, create if doesn’t exist
get_saved_array_new
Section titled “get_saved_array_new”function get_saved_array_new(name: string, size: number): SfallList<any>
Create new saved array, free old one if exists
get_saved_array_new_map
Section titled “get_saved_array_new_map”function get_saved_array_new_map(name: string): SfallMap<any, any>
Create new saved array map, free old one if exists