| 181 | } |
| 182 | |
| 183 | public ISeq seqFrom(Object key, boolean ascending){ |
| 184 | if(_count > 0) |
| 185 | { |
| 186 | ISeq stack = null; |
| 187 | Node t = tree; |
| 188 | while(t != null) |
| 189 | { |
| 190 | int c = doCompare(key, t.key); |
| 191 | if(c == 0) |
| 192 | { |
| 193 | stack = RT.cons(t, stack); |
| 194 | return new Seq(stack, ascending); |
| 195 | } |
| 196 | else if(ascending) |
| 197 | { |
| 198 | if(c < 0) |
| 199 | { |
| 200 | stack = RT.cons(t, stack); |
| 201 | t = t.left(); |
| 202 | } |
| 203 | else |
| 204 | t = t.right(); |
| 205 | } |
| 206 | else |
| 207 | { |
| 208 | if(c > 0) |
| 209 | { |
| 210 | stack = RT.cons(t, stack); |
| 211 | t = t.right(); |
| 212 | } |
| 213 | else |
| 214 | t = t.left(); |
| 215 | } |
| 216 | } |
| 217 | if(stack != null) |
| 218 | return new Seq(stack, ascending); |
| 219 | } |
| 220 | return null; |
| 221 | } |
| 222 | |
| 223 | public NodeIterator iterator(){ |
| 224 | return new NodeIterator(tree, true); |