public Object reduce(IFn f, Object val) { Object acc = val; long i = start; do { acc = f.invoke(acc, i); if (RT.isReduced(acc)) return ((Reduced)acc).deref(); i += step; } while(! boundsCheck.exceededBounds(i)); return acc; }
public Object reduce(IFn f) { Object acc = start; long i = start + step; while(! boundsCheck.exceededBounds(i)) { acc = f.invoke(acc, i); if (acc instanceof Reduced) return ((Reduced)acc).deref(); i += step; } return acc; }
public ISeq next() { if(_next != null) return _next; forceChunk(); if(_chunk.count() > 1) { LongChunk smallerChunk = _chunk.dropFirst(); _next = new LongRange(smallerChunk.first(), end, step, boundsCheck, smallerChunk, _chunkNext); return _next; } return chunkedNext(); }
public Object invoke(Object arg1) { switch(getRequiredArity()) { case 0: return doInvoke(ArraySeq.create(Util.ret1(arg1, arg1 = null))); case 1: return doInvoke(Util.ret1(arg1, arg1 = null), null); default: return throwArity(1); } }
public static ISeq create(final long start, long end, long step) { if(step > 0) { if(end <= start) return PersistentList.EMPTY; return new LongRange(start, end, step, positiveStep(end)); } else if(step < 0) { if(end >= start) return PersistentList.EMPTY; return new LongRange(start, end, step, negativeStep(end)); } else { if(end == start) return PersistentList.EMPTY; return Repeat.create(start); } }
public Object dispatch(IFn fn, ISeq args, Executor exec) { Throwable error = getError(); if(error != null) { throw Util.runtimeException("Agent is failed, needs restart", error); } Action action = new Action(this, fn, args, exec); dispatchAction(action); return this; }
public ISeq next(){ if(chunk.count() > 1) return new ChunkedCons(chunk.dropFirst(), _more); return chunkedNext(); }
public ISeq more(){ if(chunk.count() > 1) return new ChunkedCons(chunk.dropFirst(), _more); if(_more == null) return PersistentList.EMPTY; return _more; }
public static int hashUnordered(Iterable xs){ int hash = 0; int n = 0; for(Object x : xs) { hash += Util.hasheq(x); ++n; } return mixCollHash(hash, n); }
public static int hashOrdered(Iterable xs){ int n = 0; int hash = 1; for(Object x : xs) { hash = 31 * hash + Util.hasheq(x); ++n; } return mixCollHash(hash, n); }