export declare namespace ArrayTools { /** * * @param array * @returns shuffled copy of array * @deprecated use new Random().Shuffle() instead */ function Shuffle(array: readonly T[]): T[]; /**removes the element from the array */ function RemoveElementFromArray(array: T[], element: T): T | undefined; /**removes all or 1 elements if they check function returns true * @param [stop_on_first=true] * @returns removed elements */ function RemoveFromArray(array: T[], check: (element: T) => boolean, stop_on_first?: boolean): T[]; function IncludesOneOf(array: readonly T[], possible_elements: T[]): boolean; /**@returns same elements in the arrays */ function GetIntersection(array_0: readonly T[], array_1: readonly T[]): T[]; /**if insert_check returns true, element will be inserted at index of value that it's getting compared to * @param a - inserted value * @param b - other value */ function SortedInsert(array: T[], value: T, insert_check: (current_value: T, b: T, index: number, array: T[]) => boolean): void; /** * interts elements at position * @param array * @param elements * @param position */ function InsertElements(array: Array, elements: Array, position?: number): T[]; /**pushes element to the array if it doesnt exist */ function PushIfDoesntExist(array: Array, element: T): void; /** * @param arrays * @returns array that contains all elements from arrays */ function JoinArrays(arrays: readonly T[][]): T[]; function GetRandomElement(array: readonly T[]): T; type WeigtedArray = Array<[number, T]>; function WeightedPick(array: WeigtedArray): T; /**filters the same value, if selector is undefined will use the element itself to compare * overrides array and retuns it */ function FilterSame(array: Array, selector?: (element: T) => Q): T[]; /** * * @param array * @param start * @param finish * @returns cut copy of array */ function SubArray(array: readonly T[], start: number, finish: number): T[]; /** * compares 2 array, returns true if they have same elements */ function Compare(array_0: readonly T[], array_1: readonly T[], selector?: (array: readonly T[]) => Q): boolean; /** * loops in the opposite direction * equivalent to for(let i = array.size() - 1; i >= 0, i--) */ function ReverseLoop(array: readonly T[], callback: (value: T, index: number, array: readonly T[]) => void): void; /**swaps elements in the table by indexes */ function SwapIndexes(array: T[], index_0: number, index_1: number): void; /** * @param array * @returns reversed copy of array */ function Reverse(array: readonly T[]): T[]; /** * indexes the array and wraps the index * equivalent to array[index % array.size()] */ function WrapIndex(array: readonly T[], index: number): T; /** * makes binary search in sorted array * @param array * @param element * @param return_min if didnt find the element and this is true, will return the index of the closes smallest element * @returns index of the element, -1 if didnt find the element */ function BinarySearch(array: readonly number[], element: number, return_min?: boolean): number; /** * makes binary search in sorted array * @param array * @param element * @param return_min if didnt find the element and this is true, will return the index of the closes smallest element * @returns index of the element, -1 if didnt find the element */ function BinarySearchObject(array: readonly T[], element: number, selector: (element: T) => number, return_min?: boolean): number; function CountElement(array: readonly T[], search_element: Q, selector?: (item: T) => Q): number; /** * splits array on arrays with fixed amount of components or less * @param array * @param amount_per_table * @returns */ function SplitArray(array: readonly T[], amount_per_table: number): (readonly T[])[]; /** * converts array to map * @param array array of elements to convert to the map * @param selector returns [key, value] for map * @returns map */ function ToMap(array: readonly T[], selector: (value: T, index: number, array: readonly T[]) => [key: K, value: V]): Map; }