* Create an iterator over this tree that traverses the tree in-order (LNR, * Left-Node-Right). * * @example Using the in-order LNR iterator * ```ts * import { BinarySearchTree } from "@std/data-structures"; * import { assertEquals } from "@std/assert"; * * const tree = Binary
()
| 600 | * @returns An iterator that traverses the tree in-order (LNR). |
| 601 | */ |
| 602 | *lnrValues(): IterableIterator<T> { |
| 603 | const nodes: BinarySearchNode<T>[] = []; |
| 604 | let node: BinarySearchNode<T> | null = this.#root; |
| 605 | while (nodes.length || node) { |
| 606 | if (node) { |
| 607 | nodes.push(node); |
| 608 | node = node.left; |
| 609 | } else { |
| 610 | node = nodes.pop()!; |
| 611 | yield node.value; |
| 612 | node = node.right; |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | /** |
| 618 | * Create an iterator over this tree that traverses the tree in reverse |
no test coverage detected