@cute-dw/core
Version:
This TypeScript library is the main part of a more powerfull package designed for the fast WEB software development. The cornerstone of the library is the **DataStore** class, which might be useful when you need a full control of the data, but do not need
134 lines (133 loc) • 4.57 kB
TypeScript
import { Observable, Subject } from "rxjs";
import { Dictionary } from "./Dictionary";
import { Element } from "./Collection";
import { Comparator } from "../util/Comparator";
import { AbstractMap } from "./AbstractMap";
import { NavigableMap } from "./NavigableMap";
import { Cloneable } from "../util/interface/Cloneable";
/**
* An AVL-tree based `NavigableMap` implementation. The map is sorted according to the natural ordering of its keys, or by a `Comparator` provided at map creation time, depending on which constructor is used.
*/
export declare class TreeMap<K, V> extends AbstractMap<K, V> implements NavigableMap<K, V>, Cloneable {
private readonly _tree;
private _size;
readonly contentChanged$: Subject<void>;
constructor(comparator?: Comparator<K>);
get comparator(): Comparator<K>;
get contentChanged(): Observable<void>;
get size(): number;
clear(): void;
clone(): TreeMap<K, V>;
/** Returns the first (lowest) key currently in this map */
firstKey(): K | undefined;
/**
* @override
*/
firstEntry(): [K, V] | undefined;
/** Returns the last (highest) key currently in this map */
lastKey(): K | undefined;
/**
* @override
*/
lastEntry(): [K, V] | undefined;
/**
* @override
*/
pollLastEntry(): [K, V] | undefined;
/**
* @override
*/
pollFirstEntry(): [K, V] | undefined;
/** Returns the maximal level of the tree */
height(): number;
/**
* Gets the keys of this tree as a `Set` collection
* @returns Set
*/
keySet(): Set<K>;
/**
* @override
*/
ceilingKey(key: K): K | undefined;
/**
* @override
*/
floorKey(key: K): K | undefined;
/**
* @override
*/
lowerKey(key: K): K | undefined;
/**
* @override
*/
higherKey(key: K): K | undefined;
/**
* Gets array of the keys
* @returns Array
*/
keys(): IterableIterator<K>;
/**
* Gets array of the values
* @returns Array
*/
values(): IterableIterator<V>;
/**
* Gets array of the tree entries
* @returns Array
*/
entries(): IterableIterator<[K, V]>;
/**
* Returns _true_ if this tree contains a mapping for the specified `key`
* @see {@link has}
*/
containsKey(key: K): boolean;
/** Returns _true_ if this tree contains a value, _false_ otherwise */
containsValue(value: V): boolean;
/** Returns the value to which the `key` is mapped in this tree */
get(key: K): V | undefined;
/** Returns the value to which the `key` is mapped in this tree, or `defaultValue` if this tree contains no mapping for the key */
getOrDefault(key: K, defaultValue: Element<V>): Element<V>;
/**
* Tests the tree for the `key` existence
* @param key A key value to test
* @returns _true_ if this tree contains a mapping for the specified `key`, _false_ otherwise
* @see {@link containsKey}
*/
has(key: K): boolean;
/**
* Maps the specified `key` to the specified `value` in this tree and returns previous value of the mapping
* @param key A key value of the mapping
* @param value New value to assign for the `key`
* @returns Old value of the `key` or _undefined_ if it was not set before
* @throws IllegalArgumentException
*/
put(key: K, value: V): V | undefined;
/** Copies all of the mappings from the specified map to this tree */
putAll<Key extends K, Value extends V>(map: Dictionary<Key, Value> | Map<Key, Value>): void;
/** Removes the `key` (and its corresponding value) from this tree */
remove(key: K): Element<V> | undefined;
/**
* @override
* @throws IllegalArgumentException
*/
set(key: K, value: V): this;
/**
* Performs the specified action for each element in the tree.
* @param callBack Function to call on each tree item
* @param thisArg An object to which the `this` keyword can refer in the `callBack` function. If `thisArg` is omitted, undefined is used as the `this` value
*/
forEach(callBack: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
/**
* @override
*/
[Symbol.toStringTag]: string;
/**
* @override
*/
[Symbol.iterator](): IterableIterator<[K, V]>;
/**
* @override
*/
toString(): string;
print(): string;
}