ts-collection
Version:
This is re-write of the java collection classes in typescript. There is some tweak as typescript templates are not as equivalent as Java.
61 lines (60 loc) • 1.9 kB
TypeScript
import { Comparator } from "./comparator";
import { TreeMapEntry } from "./treemaputil/TreeMapEntry";
export declare enum RedBlackColor {
RED = 0,
BLACK = 1
}
export declare class RedBlackTreeNode<V> {
value: V;
left: RedBlackTreeNode<V>;
right: RedBlackTreeNode<V>;
parent: RedBlackTreeNode<V>;
color: RedBlackColor;
constructor(value: V, parent?: RedBlackTreeNode<V>);
}
export declare class RedBlackTree<V> {
private m_Root;
private m_Comparator;
private m_Size;
modCount: number;
constructor(comparator?: Comparator<V>);
comparator(): Comparator<V>;
contains(value: V): boolean;
remove(value: V): V;
clear(): void;
put(value: V): V;
getPredecessor(value: V): V;
getSuccessor(value: V): V;
getFirstNode(): RedBlackTreeNode<V>;
getLastNode(): RedBlackTreeNode<V>;
compareValues(v1: V, v2: V): number;
getCeilingNode(value: V): RedBlackTreeNode<V>;
getFloorNode(value: V): RedBlackTreeNode<V>;
getHigherNode(value: V): RedBlackTreeNode<V>;
getLowerNode(value: V): RedBlackTreeNode<V>;
isEmpty(): boolean;
size(): number;
getRedBlackTreeNode(value: V): RedBlackTreeNode<V>;
private getNodeUsingComparator;
private colorOf;
private setColor;
private leftOf;
private rightOf;
private parentOf;
private rotateLeft;
private rotateRight;
private fixAfterInsertion;
successor(t: RedBlackTreeNode<V>): RedBlackTreeNode<V>;
static key<K, V>(entry: TreeMapEntry<K, V>): K;
static entryOrNull<V>(node: RedBlackTreeNode<V>): V;
/**
* Returns the predecessor of the specified Entry, or null if no such.
*/
predecessor(t: RedBlackTreeNode<V>): RedBlackTreeNode<V>;
/**
* Delete node p, and then rebalance the tree.
*/
deleteEntry(p: RedBlackTreeNode<V>): void;
/** From CLR */
private fixAfterDeletion;
}