( self: RBT.RedBlackTree<K, V>, key: K, direction: RBT.RedBlackTree.Direction )
| 520 | >(2, (self, key) => greaterThan(self, key, Direction.Forward)) |
| 521 | |
| 522 | const greaterThan = <K, V>( |
| 523 | self: RBT.RedBlackTree<K, V>, |
| 524 | key: K, |
| 525 | direction: RBT.RedBlackTree.Direction |
| 526 | ): Iterable<[K, V]> => { |
| 527 | return { |
| 528 | [Symbol.iterator]: () => { |
| 529 | const cmp = (self as RedBlackTreeImpl<K, V>)._ord |
| 530 | let node = (self as RedBlackTreeImpl<K, V>)._root |
| 531 | const stack = [] |
| 532 | let last_ptr = 0 |
| 533 | while (node !== undefined) { |
| 534 | const d = cmp(key, node.key) |
| 535 | stack.push(node) |
| 536 | if (d < 0) { |
| 537 | last_ptr = stack.length |
| 538 | } |
| 539 | if (d < 0) { |
| 540 | node = node.left |
| 541 | } else { |
| 542 | node = node.right |
| 543 | } |
| 544 | } |
| 545 | stack.length = last_ptr |
| 546 | return new RedBlackTreeIterator(self, stack, direction) |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | /** @internal */ |
| 552 | export const greaterThanEqualBackwards = dual< |
no outgoing calls
no test coverage detected