import type { RedBlackTree } from "@tsplus/stdlib/collections/RedBlackTree/definition" import { _K, _V, RedBlackTreeIterator, RedBlackTreeSym } from "@tsplus/stdlib/collections/RedBlackTree/definition" import type { Node } from "@tsplus/stdlib/collections/RedBlackTree/node" export class RedBlackTreeInternal implements RedBlackTree { readonly [RedBlackTreeSym]: RedBlackTreeSym = RedBlackTreeSym readonly [_K]!: () => K readonly [_V]!: () => V constructor(readonly ord: Ord, readonly root: Node | undefined) {} [Symbol.iterator](): RedBlackTreeIterator { const stack: Node[] = [] let n = this.root while (n) { stack.push(n) n = n.left } return new RedBlackTreeIterator(this, stack, "Forward") } [Hash.sym](): number { return Hash.iterator(this[Symbol.iterator]()) } [Equals.sym](that: unknown): boolean { return ( that instanceof RedBlackTreeInternal && (this.root?.count ?? 0) === (that.root?.count ?? 0) && this == that ) } }