type Comparator<T, E = T> = (a: E, b: T) => number;
export declare function shuffleArray<T>(array: T[]): void;
/**
 * Gets a random subset of size n from the array
 * @param arr
 * @param n
 * @returns
 */
export declare function getRandom<T>(arr: T[], n: number): T[];
export declare function insertSorted<T>(arr: T[], item: T, comparator?: Comparator<T>): number;
export declare function linearInsertSorted<T>(arr: T[], item: T, comparator: Comparator<T>): void;
/**
 * Binary find lowest
 * Returns the index of the lowest element in the array. The array is monotonically increasing to the right, but
 *     can have a break in the middle. For example
 * [ 5, 8, 1, 2, 4]
 * Notice the break is at index 1 when the value drops from 8 to 1, but is other increasing to the right
 * The index to be returned in this case is 2 which is the indes of the lowest value.
 * In the following example the index to be returned is also 2.
 * [ 5, 8, 1, 1, 4]
 * So when the lowest value is repeated we should return the indes of the left most lowest element.
 * In the following example the index to be returned is 0.
 * [ 2, 3, 5, 7, 8]
 * The simple way of doing this is to scan the whole array to find the left most lowest element.
 * However if the array is very long it is faster to use a binary search to find it.
 * This is used when we refresh nodes.
 *
 * Parameters:
 *     ar - A sorted array
 *     compare_fn - A comparator function. The function takes two arguments: (a, b) and returns:
 *        a positive number if a is greater than b.
 *        a negative number if a is less than b.
 *        0 if a is equal to b;
 * The array may contain duplicate elements. If there are more than one lowest elements in the array,
 * the returned value will be the index of the left most lowest element
 */
export declare function binaryLowest<T>(ar: T[], comparator?: Comparator<T>): number;
/**
 * Binary search in JavaScript.
 * Returns the index of of the element in a sorted array or (-n-1) where n is the insertion point for the new element.
 *   If the return value is negative use 1-returned as the insertion point for the element
 * Parameters:
 *     arr - A sorted array
 *     el - An element to search for
 *     compare_fn - A comparator function. The function takes two arguments: (el, ae) and returns:
 *       a negative number  if el is less than ae;
 *       a positive number if el is greater than ae.
 *       0 if el is equal to ae;
 *       note that el is the element we are searching for and ae is an array element from the sorted array
 * The array may contain duplicate elements. If there are more than one equal elements in the array,
 * the returned value can be the index of any one of the equal elements.
 *
 * @param arr
 * @param el
 * @param comparator
 */
export declare function binarySearch<T, E = Partial<T>>(arr: T[], el: E, comparator?: Comparator<T, typeof el>): number;
export declare const computeMedian: (arr?: number[], sort?: boolean) => number;
export {};
