range-ts
Version:
RangeMap implementation based on Guava
44 lines • 1.66 kB
TypeScript
import { NumberRange } from "../number-range/number-range";
export interface RangeValue<T> {
range: NumberRange;
value: T;
}
export declare class RangeMap<T> {
private eq;
private rangeValues;
private static fromRangeValues;
constructor(eq?: (a: T, b: T) => boolean);
put(range: NumberRange, value: T): void;
putCoalescing(range: NumberRange, value: T): void;
/**
* Returns the value associated with the specified key, or null if there is no such value.
*/
get(value: number): T | null;
/**
* Returns a sorted copy of current values in this RangeMap
*/
asMapOfRanges(): Map<NumberRange, T>;
/**
* Returns a sorted map with the provided value as the key
*/
asMapOfValues(): Map<T, NumberRange[]>;
/**
* Returns a view of the part of this range map that intersects with range.
*/
subRangeMap(range: NumberRange): RangeMap<T>;
/**
* Returns the range containing this key and its associated value, if such a range is present in the range map, or null otherwise.
*/
getEntry(key: number): [NumberRange, T] | null;
/**
* Returns the minimal range enclosing the ranges in this RangeMap.
*/
span(): NumberRange | null;
/**
* Removes all associations from this range map in the specified range (optional operation).
* If !range.contains(k), get(k) will return the same result before and after a call to remove(range). If range.contains(k), then after a call to remove(range), get(k) will return null.
*/
remove(range: NumberRange): void;
private combinedPut;
}
//# sourceMappingURL=range-map.d.ts.map