/** * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal */ import * as Impl from './impl/interval'; namespace Interval { export const Empty: Interval = Impl.Empty as any; export const ofSingleton: (value: T) => Interval = (v) => Impl.ofRange(v, v) as any; /** Create interval from range [min, max] */ export const ofRange: (min: T, max: T) => Interval = Impl.ofRange as any; /** Create interval from bounds [start, end), i.e. [start, end - 1] */ export const ofBounds: (start: T, end: T) => Interval = Impl.ofBounds as any; /** Create interval from length [0, length), i.e. [0, length - 1] */ export const ofLength: (length: T) => Interval = Impl.ofLength as any; export const is: (v: any) => v is Interval = Impl.is as any; /** Test if a value is within the bounds of the interval */ export const has: (interval: Interval, x: T) => boolean = Impl.has as any; /** Returns the index of `x` in `set` or -1 if not found. */ export const indexOf: (interval: Interval, x: T) => number = Impl.indexOf as any; export const getAt: (interval: Interval, i: number) => T = Impl.getAt as any; /** Start value of the Interval, same as min value */ export const start: (interval: Interval) => T = Impl.start as any; /** End value of the Interval, same as max + 1 */ export const end: (interval: Interval) => T = Impl.end as any; /** Min value of the Interval, same as start value */ export const min: (interval: Interval) => T = Impl.min as any; /** Max value of the Interval, same as end - 1 */ export const max: (interval: Interval) => T = Impl.max as any; /** Number of values in the interval */ export const size: (interval: Interval) => number = Impl.size as any; /** Hash code describing the interval */ export const hashCode: (interval: Interval) => number = Impl.hashCode as any; /** String representation of the interval */ export const toString: (interval: Interval) => string = Impl.toString as any; /** Test if two intervals are identical */ export const areEqual: (a: Interval, b: Interval) => boolean = Impl.areEqual as any; /** Test if two intervals are intersecting, i.e. their bounds overlap */ export const areIntersecting: (a: Interval, b: Interval) => boolean = Impl.areIntersecting as any; /** Test if interval b is fully included in interval a */ export const isSubInterval: (a: Interval, b: Interval) => boolean = Impl.isSubInterval as any; export const findPredecessorIndex: (interval: Interval, x: T) => number = Impl.findPredecessorIndex as any; export const findPredecessorIndexInInterval: (interval: Interval, x: T, bounds: Interval) => number = Impl.findPredecessorIndexInInterval as any; export const findRange: (interval: Interval, min: T, max: T) => Interval = Impl.findRange as any; /** Size of the intersection of the two intervals */ export const intersectionSize: (a: Interval, b: Interval) => number = Impl.intersectionSize as any; /** Get a new interval that is the intersection of the two intervals */ export const intersect: (a: Interval, b: Interval) => Interval = Impl.intersect as any; } /** Interval describing a range [min, max] of values */ interface Interval { '@type': 'int-interval' } export default Interval;