( self: RBT.RedBlackTree<K, V>, key: K, direction: RBT.RedBlackTree.Direction )
| 602 | >(2, (self, key) => lessThan(self, key, Direction.Forward)) |
| 603 | |
| 604 | const lessThan = <K, V>( |
| 605 | self: RBT.RedBlackTree<K, V>, |
| 606 | key: K, |
| 607 | direction: RBT.RedBlackTree.Direction |
| 608 | ): Iterable<[K, V]> => { |
| 609 | return { |
| 610 | [Symbol.iterator]: () => { |
| 611 | const cmp = (self as RedBlackTreeImpl<K, V>)._ord |
| 612 | let node = (self as RedBlackTreeImpl<K, V>)._root |
| 613 | const stack = [] |
| 614 | let last_ptr = 0 |
| 615 | while (node !== undefined) { |
| 616 | const d = cmp(key, node.key) |
| 617 | stack.push(node) |
| 618 | if (d > 0) { |
| 619 | last_ptr = stack.length |
| 620 | } |
| 621 | if (d <= 0) { |
| 622 | node = node.left |
| 623 | } else { |
| 624 | node = node.right |
| 625 | } |
| 626 | } |
| 627 | stack.length = last_ptr |
| 628 | return new RedBlackTreeIterator(self, stack, direction) |
| 629 | } |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | /** @internal */ |
| 634 | export const lessThanEqualBackwards = dual< |
no outgoing calls
no test coverage detected