/** * Copyright (c) 2017-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal */ import * as Impl from './impl/sorted-array'; import { Interval } from './interval'; namespace SortedArray { export const Empty: SortedArray = Impl.Empty as any; export const ofUnsortedArray: (xs: ArrayLike) => SortedArray = Impl.ofUnsortedArray as any; export const ofSingleton: (v: number) => SortedArray = Impl.ofSingleton as any; export const ofSortedArray: (xs: ArrayLike) => SortedArray = Impl.ofSortedArray as any; /** create sorted array [min, max] (it DOES contain the max value) */ export const ofRange: (min: T, max: T) => SortedArray = Impl.ofRange as any; /** create sorted array [min, max) (it does NOT contain the max value) */ export const ofBounds: (min: T, max: T) => SortedArray = (min, max) => Impl.ofRange(min, max - 1) as any; export const is: (v: any) => v is SortedArray = Impl.is as any; export const isRange: (array: ArrayLike) => boolean = Impl.isRange as any; export const has: (array: SortedArray, x: T) => boolean = Impl.has as any; /** Returns the index of `x` in `set` or -1 if not found. */ export const indexOf: (array: SortedArray, x: T) => number = Impl.indexOf as any; export const indexOfInInterval: (array: SortedArray, x: number, bounds: Interval) => number = Impl.indexOfInInterval as any; export const indexOfInRange: (array: SortedArray, x: number, start: number, end: number) => number = Impl.indexOfInRange as any; /** Returns `array[0]` */ export const start: (array: SortedArray) => T = Impl.start as any; /** Returns `array[array.length - 1] + 1` */ export const end: (array: SortedArray) => T = Impl.end as any; export const min: (array: SortedArray) => T = Impl.min as any; export const max: (array: SortedArray) => T = Impl.max as any; export const size: (array: SortedArray) => number = Impl.size as any; export const hashCode: (array: SortedArray) => number = Impl.hashCode as any; export const toString: (array: SortedArray) => string = Impl.toString as any; export const areEqual: (a: SortedArray, b: SortedArray) => boolean = Impl.areEqual as any; export const areIntersecting: (a: SortedArray, b: SortedArray) => boolean = Impl.areIntersecting as any; export const isSubset: (a: SortedArray, b: SortedArray) => boolean = Impl.isSubset as any; export const union: (a: SortedArray, b: SortedArray) => SortedArray = Impl.union as any; export const intersect: (a: SortedArray, b: SortedArray) => SortedArray = Impl.intersect as any; export const subtract: (a: SortedArray, b: SortedArray) => SortedArray = Impl.subtract as any; export const findPredecessorIndex: (array: SortedArray, x: T) => number = Impl.findPredecessorIndex as any; export const findPredecessorIndexInInterval: (array: SortedArray, x: T, bounds: Interval) => number = Impl.findPredecessorIndexInInterval as any; export const findRange: (array: SortedArray, min: T, max: T) => Interval = Impl.findRange as any; export const intersectionSize: (a: SortedArray, b: SortedArray) => number = Impl.intersectionSize as any; export const deduplicate: (array: SortedArray) => SortedArray = Impl.deduplicate as any; /** Returns indices of xs in the array. E.g. indicesOf([10, 11, 12], [10, 12]) ==> [0, 2] */ export const indicesOf: (array: SortedArray, xs: SortedArray) => SortedArray = Impl.indicesOf as any; } interface SortedArray extends ArrayLike { '@type': 'int-sorted-array' } export { SortedArray };