MCPcopy Index your code
hub / github.com/clojure/clojure / Seq

Class Seq

src/jvm/clojure/lang/PersistentArrayMap.java:365–435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365static class Seq extends ASeq implements Counted, IReduce, IDrop {
366 final Object[] array;
367 final int i;
368
369 Seq(Object[] array, int i){
370 this.array = array;
371 this.i = i;
372 }
373
374 public Seq(IPersistentMap meta, Object[] array, int i){
375 super(meta);
376 this.array = array;
377 this.i = i;
378 }
379
380 public Object first(){
381 return MapEntry.create(array[i],array[i+1]);
382 }
383
384 public ISeq next(){
385 if(i + 2 < array.length)
386 return new Seq(array, i + 2);
387 return null;
388 }
389
390 public int count(){
391 return (array.length - i) / 2;
392 }
393
394 public Sequential drop(int n) {
395 if(n < count()) {
396 return new Seq(array, i + (2 * n));
397 } else {
398 return null;
399 }
400 }
401
402 public Obj withMeta(IPersistentMap meta){
403 if(meta() == meta)
404 return this;
405 return new Seq(meta, array, i);
406 }
407
408 public Iterator iterator() {
409 return new Iter(array, i-2, APersistentMap.MAKE_ENTRY);
410 }
411
412 public Object reduce(IFn f) {
413 if(i < array.length) {
414 Object acc = MapEntry.create(array[i], array[i+1]);
415 for(int j=i+2;j < array.length;j+=2){
416 acc = f.invoke(acc, MapEntry.create(array[j], array[j+1]));
417 if(RT.isReduced(acc))
418 return ((IDeref)acc).deref();
419 }
420 return acc;
421 } else {
422 return f.invoke();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected