| 209 | } |
| 210 | |
| 211 | private static class LongChunk implements IChunk, Serializable { |
| 212 | final long start; |
| 213 | final long step; |
| 214 | final int count; |
| 215 | |
| 216 | public LongChunk(long start, long step, int count) { |
| 217 | this.start = start; |
| 218 | this.step = step; |
| 219 | this.count = count; |
| 220 | } |
| 221 | |
| 222 | public long first(){ |
| 223 | return start; |
| 224 | } |
| 225 | |
| 226 | public Object nth(int i){ |
| 227 | return start + (i * step); |
| 228 | } |
| 229 | |
| 230 | public Object nth(int i, Object notFound){ |
| 231 | if(i >= 0 && i < count) |
| 232 | return start + (i * step); |
| 233 | return notFound; |
| 234 | } |
| 235 | |
| 236 | public int count(){ |
| 237 | return count; |
| 238 | } |
| 239 | |
| 240 | public LongChunk dropFirst(){ |
| 241 | if(count <= 1) |
| 242 | throw new IllegalStateException("dropFirst of empty chunk"); |
| 243 | return new LongChunk(start+step, step, count-1); |
| 244 | } |
| 245 | |
| 246 | public Object reduce(IFn f, Object init) { |
| 247 | long x = start; |
| 248 | Object ret = init; |
| 249 | for(int i=0; i<count; i++) { |
| 250 | ret = f.invoke(ret, x); |
| 251 | if(RT.isReduced(ret)) |
| 252 | return ret; |
| 253 | x += step; |
| 254 | } |
| 255 | return ret; |
| 256 | } |
| 257 | |
| 258 | } |
| 259 | } |
nothing calls this directly
no outgoing calls
no test coverage detected