sorted-array.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. */
  6. import * as Impl from './impl/sorted-array'
  7. import Interval from './interval'
  8. namespace SortedArray {
  9. export const ofUnsortedArray: (xs: ArrayLike<number>) => SortedArray = Impl.ofUnsortedArray as any;
  10. export const ofSortedArray: (xs: ArrayLike<number>) => SortedArray = Impl.ofSortedArray as any;
  11. export const is: (v: any) => v is Interval = Impl.is as any;
  12. export const values: (array: SortedArray) => ArrayLike<number> = (xs) => xs as any;
  13. export const has: (array: SortedArray, x: number) => boolean = Impl.has as any;
  14. export const indexOf: (array: SortedArray, x: number) => number = Impl.indexOf as any;
  15. export const indexOfInterval: (array: SortedArray, x: number, bounds: Interval) => number = Impl.indexOfInterval as any;
  16. export const getAt: (array: SortedArray, i: number) => number = Impl.getAt as any;
  17. export const start: (array: SortedArray) => number = Impl.start as any;
  18. export const end: (array: SortedArray) => number = Impl.end as any;
  19. export const min: (array: SortedArray) => number = Impl.min as any;
  20. export const max: (array: SortedArray) => number = Impl.max as any;
  21. export const size: (array: SortedArray) => number = Impl.size as any;
  22. export const hashCode: (array: SortedArray) => number = Impl.hashCode as any;
  23. export const areEqual: (a: SortedArray, b: SortedArray) => boolean = Impl.areEqual as any;
  24. export const findPredecessorIndex: (array: SortedArray, x: number) => number = Impl.findPredecessorIndex as any;
  25. export const findPredecessorIndexInInterval: (array: SortedArray, x: number, bounds: Interval) => number = Impl.findPredecessorIndexInInterval as any;
  26. export const findRange: (array: SortedArray, min: number, max: number) => Interval = Impl.findRange as any;
  27. }
  28. interface SortedArray { '@type': 'int-sorted-array' }
  29. export default SortedArray