* Create an iterator over this tree that traverses the tree in pre-order (NLR, * Node-Left-Right). * * @example Using the pre-order NLR iterator * ```ts * import { BinarySearchTree } from "@std/data-structures"; * import { assertEquals } from "@std/assert"; * * const tree = B
()
| 661 | * @returns An iterator that traverses the tree in pre-order (NLR). |
| 662 | */ |
| 663 | *nlrValues(): IterableIterator<T> { |
| 664 | const nodes: BinarySearchNode<T>[] = []; |
| 665 | if (this.#root) nodes.push(this.#root); |
| 666 | while (nodes.length) { |
| 667 | const node: BinarySearchNode<T> = nodes.pop()!; |
| 668 | yield node.value; |
| 669 | if (node.right) nodes.push(node.right); |
| 670 | if (node.left) nodes.push(node.left); |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | /** |
| 675 | * Create an iterator over this tree that traverses the tree in post-order (LRN, |
no test coverage detected