@foxglove/avl
Version:
Adelson-Velsky-Landis (AVL) self-balancing binary trees in TypeScript
29 lines • 978 B
TypeScript
export declare type AVLNode<K, V> = {
parent?: AVLNode<K, V>;
left?: AVLNode<K, V>;
right?: AVLNode<K, V>;
balanceFactor: number;
key: K;
value: V;
};
/**
* Single left rotation
*/
export declare function rotateLeft<K, V>(node: AVLNode<K, V>): AVLNode<K, V>;
/**
* Single right rotation
*/
export declare function rotateRight<K, V>(node: AVLNode<K, V>): AVLNode<K, V>;
/**
* Return the node immediately after the given node in the in-order traversal
*/
export declare function nextNode<Key, Value>(node: AVLNode<Key, Value>): AVLNode<Key, Value> | undefined;
/**
* Return the node immediately before the given node in the in-order traversal
*/
export declare function prevNode<Key, Value>(node: AVLNode<Key, Value>): AVLNode<Key, Value> | undefined;
/**
* Prints tree horizontally
*/
export declare function printNodes<K, V>(root: AVLNode<K, V> | undefined, printEntry?: (entry: [K, V]) => string): string;
//# sourceMappingURL=AVLNode.d.ts.map