/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ /** * A map in which entries are always added in key-sorted order. * Supports appending and searching. */ export declare class AppendOnlySortedMap { protected readonly comparator: (a: K, b: K) => number; protected readonly elements: (K | V)[]; /** * @param comparator - a comparator for keys */ constructor(comparator: (a: K, b: K) => number); /** * Gets the size of the map. * @returns the number of entries in this map */ get size(): number; /** * Gets the min key in the map. * @returns the min key in the map. */ minKey(): K | undefined; /** * Gets the max key in the map. * @returns the max key in the map. */ maxKey(): K | undefined; /** * Gets the min value in the map. * @returns the min value in the map. */ minValue(): V | undefined; /** * Gets the max value in the map. * @returns the max value in the map. */ maxValue(): V | undefined; /** * Gets the first key/value pair in the map. * @returns the first pair if it exists, or undefined otherwise. */ first(): [K, V] | undefined; /** * Gets the last key/value pair in the map. * @returns the last pair if it exists, or undefined otherwise. */ last(): [K, V] | undefined; /** * Gets the entry at the specified index. * @param index - the entry index * @returns the key/value pair if it exists, or undefined otherwise. */ getAtIndex(index: number): [K, V] | undefined; /** * Gets the entries in the map. * @returns an iterable of the entries in the map. */ entries(): IterableIterator; /** * Gets the keys in the map. * @returns an iterable of the keys in the map. */ keys(): IterableIterator; /** * Gets the values in the map. * @returns an iterable of the values in the map. */ values(): IterableIterator; /** * Gets the entries in the map, reversed. * @returns an iterable of the entries in the map, reversed. */ entriesReversed(): IterableIterator; /** * Appends a new key/value pair at the end of the map. `key` must be greater than all other keys in the map. * @param key - the key to add * @param value - the value to add */ append(key: K, value: V): void; /** * Replaces the last key/value pair with a new one. If the map is empty, the new pair is appended. * 'key' must be greater than all other keys in the map. * @param key - the key to set * @param value - the value to set */ replaceLast(key: K, value: V): void; /** * Gets the value associated with a given key. * @param key - the key to lookup * @returns the value if it exists, or undefined otherwise. */ get(key: K): V | undefined; /** * Gets the pair associated with the given key or the next smaller key. * @param key - the key to lookup * @returns the pair if it exists, or undefined otherwise. */ getPairOrNextLower(key: K): readonly [K, V] | undefined; /** * Gets the pair associated with the given key or the next higher key. * @param key - the key to lookup. * @returns the entry associated with `key` if such an entry exists, the entry associated with the next higher key if such an entry * exists, and undefined otherwise. */ getPairOrNextHigher(key: K): readonly [K, V] | undefined; /** * Compares two `AppendOnlySortedMap`s. */ equals(other: AppendOnlySortedMap, compareValues: (a: V, b: V) => boolean): boolean; /** * Test-only expensive assertions to check the internal validity of the data structure. */ assertValid(): void; /** * Queries a range of entries. * @param from - the key to start the range query at, inclusive. * @param to - the key to end the range query at, inclusive. * @returns the range of entries. */ getRange(from: K, to: K): IterableIterator; protected getPairOrNextLowerBy(search: T, comparator: (search: T, key: K, value: V) => number): readonly [K, V] | undefined; private getKeyIndexOfOrNextLower; /** * Gets the pair associated with the given key or next higher key. * @param search - the search value * @param comparator - a comparison function * @returns the pair if it exists, or undefined otherwise. */ protected getPairOrNextHigherBy(search: T, comparator: (search: T, key: K, value: V) => number): readonly [K, V] | undefined; private getKeyIndexOfOrNextHigher; /** * The value xor'd with the result index when a search fails. */ static readonly failureXor = -1; /** * Performs a binary search on the sorted array. * @returns the index of the key for `search`, or (if not present) the index it would have been inserted into xor'd * with `failureXor`. Note that negating is not an adequate solution as that could result in -0. */ static keyIndexOf(elements: readonly (K | V)[], search: T, comparator: (search: T, key: K, value: V) => number): number; } //# sourceMappingURL=appendOnlySortedMap.d.ts.map