Splits the range of values up into blocks. It's assumed the cost to process a block is small so
more can be created.
@param start First index, inclusive
@param endExclusive Last index, exclusive
@param consumer The consumer
767171
public static void loopBlocks(int start , int endExclusive , IntRangeConsumer consumer ) {
		final ForkJoinPool pool = BoofConcurrency.pool;
		int numThreads = pool.getParallelism();

		int range = endExclusive-start;
		if( range == 0 ) // nothing to do here!
			return;
		if( range < 0 )
			throw new IllegalArgumentException("end must be more than start. "+start+" -> "+endExclusive);

		// Did some experimentation here. Gave it more threads than were needed or exactly what was needed
		// exactly seemed to do better in the test cases
		int blockSize = Math.max(1,range/numThreads);

		try {
			pool.submit(new IntRangeTask(start,endExclusive,blockSize,consumer)).get();
		} catch (InterruptedException | ExecutionException e) {
			throw new RuntimeException(e);
		}
	}
1343668
public <T> void spliterator(Spliterator<T> s, ResultStream<T> result)
  {
    ArrayList<Spliterator<T>> splits = new ArrayList<>();
    
    splits.add(s);
    
    int count = 2 * getTaskManager().getWorkers();
    split(splits, count);
    
    int size = splits.size();
    
    if (size == 1) {
      getTaskManager().run(new ComputeTask<T>(splits.get(0), result));
      // _workers.compute(splits.get(0), new ResultSinkWrapper<T>(result));
      return;
    }

    /*
    if (true) {
      throw new UnsupportedOperationException(L.l("fork unsupported for {0}", result));
    }
    */
    
    ServiceRefAmp serviceRef = ServiceRefAmp.current();
    
    //ResultStreamAmp<T> resultAmp = (ResultStreamAmp<T>) result;
    
    ResultStreamJoin<T> join = new ResultStreamJoin<T>(result, serviceRef.inbox());
    for (int i = 0; i < size; i++) {
      //resultSinkFork[i].begin(0);
      //_workers.compute(splits.get(i), new ResultSinkWrapper<T>(resultSinkFork[i]));
      
      getTaskManager().run(new ComputeTask<T>(splits.get(i), join.fork()));
    }
    
    join.ok();
  }
866420
public static ListLong limit(final ListLong data, final int start, final int end) {
        return new ListLong() {

            @Override
            public long getLong(int index) {
                return data.getLong(index + start);
            }

            @Override
            public int size() {
                return end - start;
            }
        };
    }
1289731
@Override
  public void part(int start, int end) {
    blockNumbers[count][0] = start;
    blockNumbers[count][1] = end - 1;
    count++;
  }
565908
public static int[] range(int start, int end) {
    int[] out = new int[end - start];
    for(int i = 0, j = start; j < end; i++, j++) {
      out[i] = j;
    }
    return out;
  }
420114
public int split(T obj, int start, int length) throws IOException
    {
        int count = 0;
        if (length > 0)
        {
            int end = (start + length) % size;
            if (start < end)
            {
                count = op(obj, start, end);
            }
            else
            {
                if (end > 0)
                {
                    count = op(obj, start, size, 0, end);
                }
                else
                {
                    count = op(obj, start, size);
                }
            }
        }
        assert count <= length;
        return count;
    }
34403
public static Range fromInterval(int start, int end) {
        if (start < 0) {
            throw new IllegalArgumentException("Range start must be >= 0: " + start);
        }
        if (end < 0) {
            throw new IllegalArgumentException("Range end must be >= 0: " + end);
        }
        if (end < start) {
            throw new IllegalArgumentException("Range end must be >= start: " + end + "<" + start);
        }
        return new Range(start, end - start);
    }
1050226
public List<?> range(Value begin, Value end) {
		List<Object> results = new ArrayList<Object>();
		Key[] elementKeys = getElementKeys();
		if (elementKeys != null && elementKeys.length > 0) {
			List<Record> records = fetchSubRecords(elementKeys);
			for (Record record : records) {
				if (record != null && filterBinByRange(record, ListElementBinName, begin, end)) {
					results.add(record.getValue(ListElementBinName));
				}
			}
		}
		return results;
	}
470827
public <T> List<T> range(long start,long end){
    	Set<byte[]> result = null;
        try {    		
        	if(isCluster(groupName)){
        		result = getBinaryJedisClusterCommands(groupName).zrange(keyBytes, start, end);
        	}else{
        		result = getBinaryJedisCommands(groupName).zrange(keyBytes, start, end);
        	}
        	return toObjectList(new ArrayList<>(result));
    	} finally{
			getJedisProvider(groupName).release();
		}
	}
373197
@Nonnull
	public static <T> LPredicateBuilder<T> predicate(Consumer<LPredicate<T>> consumer) {
		return new LPredicateBuilder(consumer);
	}
462310
TokenRange range(JavaToken begin, JavaToken end) {
        if (storeTokens) {
            return new TokenRange(begin, end);
        }
        return null;
    }
544946
public void saveBlocks(BigInteger startBlockNumber, BigInteger endBlockNumber)
    {

        if (endBlockNumber.compareTo(startBlockNumber) < 1)
        {
            LOGGER.error("startBlockNumber must be smaller than endBlockNumer");
            throw new KunderaException("startBlockNumber must be smaller than endBlockNumer");
        }

        if (startBlockNumber.compareTo(getFirstBlockNumber()) < 0)
        {
            LOGGER.error("start block number can't be smaller than EARLIEST block");
            throw new KunderaException("starting block number can't be smaller than EARLIEST block");
        }

        if (endBlockNumber.compareTo(getLatestBlockNumber()) > 0)
        {
            LOGGER.error("end block number can't be larger than LATEST block");
            throw new KunderaException("end block number can't be larger than LATEST block");
        }

        long diff = endBlockNumber.subtract(startBlockNumber).longValue();

        for (long i = 0; i <= diff; i++)
        {
            EthBlock block = null;
            BigInteger currentBlockNum = null;
            try
            {
                currentBlockNum = startBlockNumber.add(BigInteger.valueOf(i));
                block = web3j.ethGetBlockByNumber(DefaultBlockParameter.valueOf(currentBlockNum), true).send();
            }
            catch (IOException ex)
            {
                LOGGER.error("Not able to find block" + currentBlockNum + ". ", ex);
                throw new KunderaException("Not able to find block" + currentBlockNum + ". ", ex);
            }
            persistBlocksAndTransactions(block);
        }

    }
1194719
@Override
    public <R, A> R collect(Collector<? super T, A, R> collector) {
        Predicate<A> finished = finished(collector);
        if (finished != null) {
            BiConsumer<A, ? super T> acc = collector.accumulator();
            BinaryOperator<A> combiner = collector.combiner();
            Spliterator<T> spliterator = spliterator();
            if (!isParallel()) {
                A a = collector.supplier().get();
                if (!finished.test(a)) {
                    try {
                        // forEachRemaining can be much faster
                        // and take much less memory than tryAdvance for certain
                        // spliterators
                        spliterator.forEachRemaining(e -> {
                            acc.accept(a, e);
                            if (finished.test(a))
                                throw new CancelException();
                        });
                    } catch (CancelException ex) {
                        // ignore
                    }
                }
                return collector.finisher().apply(a);
            }
            Spliterator<A> spltr;
            if (!spliterator.hasCharacteristics(Spliterator.ORDERED)
                || collector.characteristics().contains(Characteristics.UNORDERED)) {
                spltr = new UnorderedCancellableSpliterator<>(spliterator, collector.supplier(), acc, combiner,
                        finished);
            } else {
                spltr = new OrderedCancellableSpliterator<>(spliterator, collector.supplier(), acc, combiner, finished);
            }
            return collector.finisher().apply(
                new StreamEx<>(StreamSupport.stream(spltr, true), context).findFirst().get());
        }
        return rawCollect(collector);
    }
1113814
public void setValue(int start, int end, int column, int value, int mask) {
        if (start < 0 || start > end || end > MAX_CP || column < 0
                || column >= (columns - 2)) {
            throw new IllegalArgumentException();
        }
        if (isCompacted) {
            throw new IllegalStateException("Shouldn't be called after"
                    + "compact()!");
        }

        int firstRow, lastRow;
        int limit = end + 1;
        boolean splitFirstRow, splitLastRow;
        // skip range start and limit columns
        column += 2;
        value &= mask;

        // find the rows whose ranges overlap with the input range
        // find the first and last row, always successful
        firstRow = findRow(start);
        lastRow = findRow(end);

        /*
         * Rows need to be split if they partially overlap with the input range
         * (only possible for the first and last rows) and if their value
         * differs from the input value.
         */
        splitFirstRow = (start != v[firstRow] && value != (v[firstRow + column] & mask));
        splitLastRow = (limit != v[lastRow + 1] && value != (v[lastRow + column] & mask));

        // split first/last rows if necessary
        if (splitFirstRow || splitLastRow) {
            int rowsToExpand = 0;
            if (splitFirstRow) {
                ++rowsToExpand;
            }
            if (splitLastRow) {
                ++rowsToExpand;
            }
            int newMaxRows = 0;
            if ((rows + rowsToExpand) > maxRows) {
                if (maxRows < MEDIUM_ROWS) {
                    newMaxRows = MEDIUM_ROWS;
                } else if (maxRows < MAX_ROWS) {
                    newMaxRows = MAX_ROWS;
                } else {
                    throw new IndexOutOfBoundsException(
                            "MAX_ROWS exceeded! Increase it to a higher value" +
                            "in the implementation");
                }
                int[] temp = new int[newMaxRows * columns];
                System.arraycopy(v, 0, temp, 0, rows * columns);
                v = temp;
                maxRows = newMaxRows;
            }

            // count the number of row cells to move after the last row,
            // and move them
            int count = (rows * columns) - (lastRow + columns);
            if (count > 0) {
                System.arraycopy(v, lastRow + columns, v, lastRow
                        + (1 + rowsToExpand) * columns, count);
            }
            rows += rowsToExpand;

            // split the first row, and move the firstRow pointer
            // to the second part
            if (splitFirstRow) {
                // copy all affected rows up one and move the lastRow pointer
                count = lastRow - firstRow + columns;
                System.arraycopy(v, firstRow, v, firstRow + columns, count);
                lastRow += columns;

                // split the range and move the firstRow pointer
                v[firstRow + 1] = v[firstRow + columns] = start;
                firstRow += columns;
            }

            // split the last row
            if (splitLastRow) {
                // copy the last row data
                System.arraycopy(v, lastRow, v, lastRow + columns, columns);

                // split the range and move the firstRow pointer
                v[lastRow + 1] = v[lastRow + columns] = limit;
            }
        }

        // set the "row last seen" to the last row for the range
        prevRow = lastRow / columns;

        // set the input value in all remaining rows
        firstRow += column;
        lastRow += column;
        mask = ~mask;
        for (;;) {
            v[firstRow] = (v[firstRow] & mask) | value;
            if (firstRow == lastRow) {
                break;
            }
            firstRow += columns;
        }
    }
568978
public static RubyRange<Integer> range(int start, int end) {
    return new RubyRange<>(IntegerSuccessor.getInstance(), start, end,
        Interval.CLOSED);
  }
840191
CloseableIterator<T> createIterator(int resultFlags) {
		try {
			SelectIterator<T, ID> iterator =
					statementExecutor.buildIterator(this, connectionSource, resultFlags, objectCache);
			return iterator;
		} catch (Exception e) {
			throw new IllegalStateException("Could not build iterator for " + dataClass, e);
		}
	}
320817
@Beta
    public static <T> Consumer<T> sc(final Object mutex, final Consumer<T> consumer) {
        N.checkArgNotNull(mutex, "mutex");
        N.checkArgNotNull(consumer, "consumer");

        return new Consumer<T>() {
            @Override
            public void accept(T t) {
                synchronized (mutex) {
                    consumer.accept(t);
                }
            }
        };
    }