| 534 | |
| 535 | private static final int CHUNK_SIZE = 32; |
| 536 | public static ISeq chunkIteratorSeq(final Iterator iter){ |
| 537 | if(iter.hasNext()) { |
| 538 | return new LazySeq(new AFn() { |
| 539 | public Object invoke() { |
| 540 | Object[] arr = new Object[CHUNK_SIZE]; |
| 541 | int n = 0; |
| 542 | while(iter.hasNext() && n < CHUNK_SIZE) |
| 543 | arr[n++] = iter.next(); |
| 544 | return new ChunkedCons(new ArrayChunk(arr, 0, n), chunkIteratorSeq(iter)); |
| 545 | } |
| 546 | }); |
| 547 | } |
| 548 | return null; |
| 549 | } |
| 550 | |
| 551 | static public ISeq seq(Object coll){ |
| 552 | if(coll instanceof ASeq) |