public LongChunk dropFirst(){ if(count <= 1) throw new IllegalStateException("dropFirst of empty chunk"); return new LongChunk(start+step, step, count-1); }
public LongChunk dropFirst(){ if(count <= 1) throw new IllegalStateException("dropFirst of empty chunk"); return new LongChunk(start+step, step, count-1); }
public void forceChunk() { if(_chunk != null) return; long count; try { count = rangeCount(start, end, step); } catch(ArithmeticException e) { // size of total range is > Long.MAX_VALUE so must step to count // this only happens in pathological range cases like: // (range -9223372036854775808 9223372036854775807 9223372036854775807) count = steppingCount(start, end, step); } if (count > CHUNK_SIZE) { // not last chunk long nextStart = start + (step * CHUNK_SIZE); // cannot overflow, must be < end _chunk = new LongChunk(start, step, CHUNK_SIZE); _chunkNext = new LongRange(nextStart, end, step, boundsCheck); } else { // last chunk _chunk = new LongChunk(start, step, (int) count); // count must be <= CHUNK_SIZE } }
public void forceChunk() { if(_chunk != null) return; long count; try { count = rangeCount(start, end, step); } catch(ArithmeticException e) { // size of total range is > Long.MAX_VALUE so must step to count // this only happens in pathological range cases like: // (range -9223372036854775808 9223372036854775807 9223372036854775807) count = steppingCount(start, end, step); } if (count > CHUNK_SIZE) { // not last chunk long nextStart = start + (step * CHUNK_SIZE); // cannot overflow, must be < end _chunkNext = new LongRange(nextStart, end, step, boundsCheck); _chunk = new LongChunk(start, step, CHUNK_SIZE); } else { // last chunk _chunk = new LongChunk(start, step, (int) count); // count must be <= CHUNK_SIZE } }