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

Method rnlValues

data_structures/binary_search_tree.ts:632–645  ·  view source on GitHub ↗

* Create an iterator over this tree that traverses the tree in reverse * in-order (RNL, Right-Node-Left). * * @example Using the reverse in-order RNL iterator * ```ts * import { BinarySearchTree } from "@std/data-structures"; * import { assertEquals } from "@std/assert"; * *

()

Source from the content-addressed store, hash-verified

630 * @returns An iterator that traverses the tree in reverse in-order (RNL).
631 */
632 *rnlValues(): IterableIterator<T> {
633 const nodes: BinarySearchNode<T>[] = [];
634 let node: BinarySearchNode<T> | null = this.#root;
635 while (nodes.length || node) {
636 if (node) {
637 nodes.push(node);
638 node = node.right;
639 } else {
640 node = nodes.pop()!;
641 yield node.value;
642 node = node.left;
643 }
644 }
645 }
646
647 /**
648 * Create an iterator over this tree that traverses the tree in pre-order (NLR,

Callers 2

Calls 2

pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected