| 10894 | |
| 10895 | //Visit all nodes within a range |
| 10896 | function doVisit(lo, hi, compare, visit, node) { |
| 10897 | var l = compare(lo, node.key) |
| 10898 | var h = compare(hi, node.key) |
| 10899 | var v |
| 10900 | if(l <= 0) { |
| 10901 | if(node.left) { |
| 10902 | v = doVisit(lo, hi, compare, visit, node.left) |
| 10903 | if(v) { return v } |
| 10904 | } |
| 10905 | if(h > 0) { |
| 10906 | v = visit(node.key, node.value) |
| 10907 | if(v) { return v } |
| 10908 | } |
| 10909 | } |
| 10910 | if(h > 0 && node.right) { |
| 10911 | return doVisit(lo, hi, compare, visit, node.right) |
| 10912 | } |
| 10913 | } |
| 10914 | |
| 10915 | |
| 10916 | proto.forEach = function rbTreeForEach(visit, lo, hi) { |