/**
* @license
* Copyright Larry Diamond 2018 All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/larrydiamond/typescriptcollectionsframework/blob/master/LICENSE
*/
import { Comparator } from "./Comparator";
import { Consumer } from "./Consumer";
import { ImmutableMap } from "./ImmutableMap";
import { ImmutableSet } from "./ImmutableSet";
import { JIterator } from "./JIterator";
import { MapEntry } from "./MapEntry";
import { NavigableMap } from "./NavigableMap";
/**
* A binary tree based NavigableMap implementation. The map is sorted according to a Comparator provided at map creation time.
* This implementation provides guaranteed log(n) time cost for the containsKey, get, put and remove operations.
*
* Note that the ordering maintained by a tree map must be consistent with equals if this sorted map is to correctly implement the Map interface.
* (See Comparator for a precise definition of consistent with equals.)
* This is so because the Map interface is defined in terms of the equals operation,
* but a sorted map performs all key comparisons using its Comparator,
* so two keys that are deemed equal by this method are, from the standpoint of the sorted map, equal.
* The behavior of a navigable map is well-defined even if its ordering is inconsistent with equals; it just fails to obey the general contract of the Map interface.
*
* This class corresponds to java.util.TreeMap
*/
export declare class TreeMap implements NavigableMap {
private initialElements;
private topNode;
private mapComparator;
constructor(iComparator: Comparator, initialElements?: ImmutableMap);
validateMap(): boolean;
private validateNode;
/**
* Returns an iterator over the entire entry set
* @return {Iterator} an iterator for the entry set
*/
[Symbol.iterator](): Iterator;
/**
* Removes all of the mappings from this map. The map will be empty after this call returns.
*/
clear(): void;
/**
* Returns the comparator used to order the keys in this map
* @return {Comparator} the comparator used to order the keys in this map
*/
comparator(): Comparator;
/**
* Returns the number of key-value mappings in this map.
* @return {number} the number of key-value mappings in this map
*/
size(): number;
/**
* Returns true if this map contains no key-value mappings.
* @return {boolean} true if this map contains no key-value mappings
*/
isEmpty(): boolean;
private sizeTree;
/**
* Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.
* @param {K} key key with which the specified value is to be associated
* @param {V} value value to be associated with the specified key
* @return {V} the previous value associated with key, or undefined if there was no mapping for key. (An undefined return can also indicate that the map previously associated undefined with key.)
*/
put(key: K, value: V): V;
private putNode;
/**
* Needed For Iterator
* @param {K} key the given key
* @return {K} the least key greater than key, or null if there is no such key
*/
getNextHigherKey(key: K): K;
/**
* Returns true if this map maps one or more keys to the specified value.
* @param value value whose presence in this map is to be tested
*/
containsValue(value: V): boolean;
private nextHigherNode;
/**
* Returns true if this map contains a mapping for the specified key. This method uses the comparator for the map to find the specified key
* @param {K} key key whose presence in this map is to be tested
* @return {boolean} true if this map contains a mapping for the specified key
*/
containsKey(key: K): boolean;
private getNode;
/**
* Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
* @param {K} key the key whose associated value is to be returned
* @return {V} the value to which the specified key is mapped, or null if this map contains no mapping for the key
*/
get(key: K): V;
/**
* Removes the mapping for this key from this TreeMap if present.
* @param {K} key key for which mapping should be removed
* @return {V} the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key.)
*/
remove(key: K): V;
/**
* Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.
* @param {K} key the key
* @return {MapEntry} an entry with the least key greater than or equal to key, or null if there is no such key
*/
ceilingEntry(key: K): MapEntry;
/**
* Returns the least key greater than or equal to the given key, or null if there is no such key.
* @param {K} key the key
* @return {K} the least key greater than or equal to key, or null if there is no such key
*/
ceilingKey(key: K): K;
/**
* Returns the least key greater than the given key, or null if there is no such key.
* @param {K} key the key
* @return {K} the least key greater than key, or null if there is no such key
*/
higherKey(key: K): K;
/**
* Returns a key-value mapping associated with the least key greater than the given key, or null if there is no such key.
* @param {K} key the key
* @return {MapEntry} an entry with the least key greater than key, or null if there is no such key
*/
higherEntry(key: K): MapEntry;
/**
* Returns the highest key lower than the given key, or null if there is no such key.
* @param {K} key the key
* @return {K} the highest key lower than key, or null if there is no such key
*/
lowerKey(key: K): K;
/**
* Returns a key-value mapping associated with the highest key lower than the given key, or null if there is no such key.
* @param {K} key the key
* @return {MapEntry} an entry with the highest key lower than key, or null if there is no such key
*/
lowerEntry(key: K): MapEntry;
/**
* Returns the greatest key less than or equal to the given key, or null if there is no such key.
* @param {K} key the key
* @return {K} the greatest key less than or equal to key, or null if there is no such key
*/
floorKey(key: K): K;
/**
* Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.
* @param {K} key the key
* @return {MapEntry} an entry with the greatest key less than or equal to key, or null if there is no such key
*/
floorEntry(key: K): MapEntry;
private ceilingNode;
private higherNode;
private lowerNode;
private floorNode;
/**
* Returns the first (lowest) node currently in this map.
* @return {TreeMapNode} the first (lowest) node currently in this map, returns null if the Map is empty
*/
private firstMapNode;
/**
* Returns the first (lowest) key currently in this map.
* @return {K} the first (lowest) key currently in this map, returns null if the Map is empty
*/
firstKey(): K;
/**
* Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
* @return {MapEntry} an entry with the least key, or null if this map is empty
*/
firstEntry(): MapEntry;
/**
* Returns the last (highest) node currently in this map.
* @return {TreeMapNode} the last (highest) node currently in this map, returns null if the Map is empty
*/
private lastMapNode;
/**
* Returns the last (highest) key currently in this map.
* @return {K} the last (highest) key currently in this map, returns null if the Map is empty
*/
lastKey(): K;
/**
* Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
* @return {MapEntry} an entry with the greatest key, or null if this map is empty
*/
lastEntry(): MapEntry;
/**
* Returns an ImmutableSet view of the keys contained in this map.
* The set's iterator returns the keys in ascending order.
* The set is backed by the map, so changes to the map are reflected in the set.
* If the map is modified while an iteration over the set is in progress the results of the iteration are undefined.
* @return {MapEntry} an entry with the greatest key, or null if this map is empty
*/
keySet(): ImmutableSet;
/**
* Returns an ImmutableSet view of the mappings contained in this map.
* The set's iterator returns the mappings in ascending key order.
* The set is backed by the map, so changes to the map are reflected in the set.
* If the map is modified while an iteration over the set is in progress the results of the iteration are undefined.
* The contains method on this entrySet will only compare keys not values.
* @return {MapEntry} an entry with the greatest key, or null if this map is empty
*/
entrySet(): ImmutableSet>;
/**
* Returns an ImmutableMap backed by Map
*/
immutableMap(): ImmutableMap;
/**
* Override JSON.stringify handling
*/
toJSON(): Array>;
}
export declare class TreeMapNode {
private key;
private value;
private leftNode;
private rightNode;
private parentNode;
constructor(iKey: K, iValue: V, iParent: TreeMapNode);
getKey(): K;
getValue(): V;
setValue(v: V): void;
getLeftNode(): TreeMapNode;
setLeftNode(n: TreeMapNode): void;
getRightNode(): TreeMapNode;
setRightNode(n: TreeMapNode): void;
getParentNode(): TreeMapNode;
setParentNode(n: TreeMapNode): void;
getMapEntry(): MapEntry;
}
export declare class ImmutableKeySetForTreeMap implements ImmutableSet {
private treeMap;
constructor(iTreeMap: TreeMap);
size(): number;
isEmpty(): boolean;
contains(item: K): boolean;
iterator(): JIterator;
[Symbol.iterator](): Iterator;
forEach(consumer: Consumer): void;
}
export declare class TreeMapKeySetJIterator implements JIterator {
private location;
private treeMap;
constructor(iTreeMap: TreeMap);
hasNext(): boolean;
next(): K;
}
export declare class TreeMapKeySetIterator implements Iterator {
private location;
private treeMap;
constructor(iTreeMap: TreeMap);
next(value?: any): IteratorResult;
}
export declare class ImmutableEntrySetForTreeMap implements ImmutableSet> {
private treeMap;
constructor(iTreeMap: TreeMap);
size(): number;
isEmpty(): boolean;
contains(item: MapEntry): boolean;
iterator(): JIterator>;
[Symbol.iterator](): Iterator>;
forEach(consumer: Consumer>): void;
}
export declare class TreeMapEntrySetJIterator implements JIterator> {
private location;
private treeMap;
constructor(iTreeMap: TreeMap);
hasNext(): boolean;
next(): MapEntry;
}
export declare class TreeMapEntrySetIterator implements Iterator> {
private location;
private treeMap;
constructor(iTreeMap: TreeMap);
next(value?: any): IteratorResult>;
}