MCPcopy Create free account
hub / github.com/denoland/std / lnrValues

Method lnrValues

data_structures/binary_search_tree.ts:602–615  ·  view source on GitHub ↗

* 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

()

Source from the content-addressed store, hash-verified

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

Callers 3

[Symbol.iterator]Method · 0.95

Calls 2

pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected