Skip to content

lib.arrays

Sfall array library functions Converted from headers/sfall/lib.arrays.h @author phobos2077

function map_contains_key<K, V>(arrayMap: SfallMap<K, V>, key: K): boolean

Check if key exists in map array

function get_empty_array_index<T>(array: SfallList<T>): number

Returns first index of zero value in a list array

function array_push<T>(array: SfallList<T>, item: T): SfallList<T>

Push item to end of list array, returns the array

function array_pop<T>(array: SfallList<T>): T

Remove and return last item from list array

function array_keys<K, V>(array: SfallMap<K, V>): SfallList<K>

Returns a temp list of keys from a given array

function array_values<K, V>(array: SfallMap<K, V>): SfallList<V>

Returns a temp list of values from a given array

function array_fixed<T>(array: SfallList<T>): SfallList<T>

Makes array permanent and returns it

function array_slice<T>(array: SfallList<T>, index: number, count: number): SfallList<T>

Returns a slice of list array as new temp array

function array_cut<T>(array: SfallList<T>, index: number, count: number): SfallList<T>

Remove a slice from list array and return it

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)

function clone_array<K, V>(array: SfallMap<K, V>): SfallMap<K, V>

Create a shallow copy of array as new temp array

function arrays_equal<T>(arr1: SfallList<T>, arr2: SfallList<T>): boolean

Compare two arrays for equality

function array_max(arr: SfallList<number>): number

Returns maximum element in array

function array_min(arr: SfallList<number>): number

Returns minimum element in array

function array_sum(arr: SfallList<number>): number

Returns sum of array elements

function array_random_value<T>(arr: SfallList<T>): T

Returns a random value from list array

function add_array_set<T>(array: SfallList<T>, item: T): boolean

Add item to set (list array with unique values). Returns true if added.

function remove_array_set<T>(array: SfallList<T>, item: T): boolean

Remove item from set. Returns true if removed.

function array_fill<T>(arr: SfallList<T>, pos: number, count: number, value: T): SfallList<T>

Fill array with value

function array_append<T>(arr1: SfallList<T>, arr2: SfallList<T>): SfallList<T>

Append all items from arr2 to arr1

function array_concat<T>(arr1: SfallList<T>, arr2: SfallList<T>): SfallList<T>

Concat arrays into new temp array

function load_create_array(name: string, size: number): SfallList<any>

Load saved array, create if doesn’t exist

function load_create_array_map(name: string): SfallMap<any, any>

Load saved array map, create if doesn’t exist

function get_saved_array_new(name: string, size: number): SfallList<any>

Create new saved array, free old one if exists

function get_saved_array_new_map(name: string): SfallMap<any, any>

Create new saved array map, free old one if exists