UNPKG

@drozdik.m/avl-tree

Version:

Classic implementation of AVL tree with improvements like efficient search of nth item and iterator.

28 lines (27 loc) 995 B
import { IBidirectionalIterator } from "@drozdik.m/common-interfaces/IBidirectionalIterator"; import { AVLTreeNode } from "./AVLTreeNode"; export declare class AVLTreeIterator<T> implements IBidirectionalIterator<T> { private current; constructor(node: AVLTreeNode<T>); Value(): T; HasValue(): boolean; Previous(): void; Next(): void; /** * Returns predecessor node to this node * @param node Current node */ protected Predecessor(node: AVLTreeNode<T>): AVLTreeNode<T>; /** * Returns successor node to this node * @param node Current node */ protected Successor(node: AVLTreeNode<T>): AVLTreeNode<T>; protected FindMinRec(node: AVLTreeNode<T>): AVLTreeNode<T>; protected FindMaxRec(node: AVLTreeNode<T>): AVLTreeNode<T>; /** * Returns currently selected node. Do not use unless you know what you are doing! * @returns Current node */ GetCurrentNode(): AVLTreeNode<T>; }