SortedMap
A map that provides ordering on its keys. Keys are ordered by a comparator provided at map creation time or by default as strings.
new SortedMap()
/**
* Creates an instance of SortedMap.
*
* @param iterable Iterable of pairs to create the new map with.
* @param compare Comparison function for key-value pairs sorting by key. Keys are compared as strings by default.
*/
constructor(iterable: Iterable<[K, V]> = [], protected compare: CompareFunc<K> = compareAsStrings)
size
/**
* Number of key-value pairs in the map.
*
* @readonly
*/
get size(): number;
clear()
/**
* Removes all key-value pairs from the map.
*/
clear(): void;
delete()
/**
* Removes the specified (by key) key-value pair from the map.
*
* @param key Pair key.
* @returns TRUE if the pair existed and has been removed, FALSE otherwise.
*/
delete(key: K): boolean;
entries()
entries(): IterableIterator<[K, V]>;
findGreater()
/**
* Finds the leftmost key-value pair with key greater than the specified key.
*
* @param key Pair key.
* @returns Key-value pair or undefined if key is the greatest or the map is empty.
*/
findGreater(key: K): [K, V] | undefined;
findGreaterOrEqual()
/**
* Finds the leftmost key-value pair with key greater than or equal to the specified key.
*
* @param key Pair key.
* @returns Key-value pair or undefined if key is the greatest or the map is empty.
*/
findGreaterOrEqual(key: K): [K, V] | undefined;
findLess()
/**
* Finds the rightmost key-value pair with key less than the specified key.
*
* @param key Pair key.
* @returns Key-value pair or undefined if key is the smallest or the map is empty.
*/
findLess(key: K): [K, V] | undefined;
findLessOrEqual()
/**
* Finds the rightmost key-value pair with key less than or equal to the specified key.
*
* @param key Pair key.
* @returns Key-value pair or undefined if key is the smallest or the map is empty.
*/
findLessOrEqual(key: K): [K, V] | undefined;
findMax()
/**
* Finds the greatest (by key) key-value pair in the map.
*
* @returns Key-value pair or undefined if the map is empty.
*/
findMax(): [K, V] | undefined;
findMin()
/**
* Finds the smallest (by key) key-value pair in the map.
*
* @returns Key-value pair or undefined if the map is empty.
*/
findMin(): [K, V] | undefined;
findRange()
/**
* Returns an iterable of key-value pairs for every pair in the map with start <= key < stop.
*
* @param start Pair key to start from.
* @param stop Pair key to stop on.
* @returns Iterable iterator of key-value pairs.
*/
findRange(start: K, stop: K): IterableIterator<[K, V]>;
forEach()
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any)
get()
/**
* Gets value of the specified (by key) key-value pair from the map. Throws an error if key not found.
*
* @param key Pair key.
* @returns Pair value.
*/
get(key: K): V;
has()
has(key: K): boolean;
keys()
keys(): IterableIterator<K>
isEmpty()
/**
* Checks whether the map is empty or not.
*
* @returns TRUE if the map is empty, FALSE otherwise.
*/
isEmpty(): boolean;
reversed()
/**
* Returns an iterable of key-value pairs for every key-value pair in the map in reverse order.
*
* @returns Iterable iterator of key-value pairs.
*/
reversed(): IterableIterator<[K, V]>;
set()
set(key: K, value: V): this;
values()
values(): IterableIterator<V>;
[Symbol.iterator]()
[Symbol.iterator](): IterableIterator<[K, V]>;
Last updated
Was this helpful?