Java Utililty Methods Number Range Create

List of utility methods to do Number Range Create

Description

The list of methods to do Number Range Create are organized into topic(s).

Method

double[]range(double a, double b, double step)
Generates an array going for a to b with steps of size step.
if (step <= 0.0) {
    throw new IllegalArgumentException("The argument step should be positive: " + step + " < 0");
if (a == b) {
    double[] ans = new double[1];
    ans[0] = a;
    return (ans);
int sizeOfArray = (new Double(Math.abs(a - b) / step)).intValue() + 1;
double[] ans = new double[sizeOfArray];
ans[0] = a;
if (a > b) {
    step = -step;
for (int k = 1; k < sizeOfArray; k++) {
    ans[k] = ans[k - 1] + step;
return (ans);
doublerange(double value1, double value2)
Calculates the range of any two real numbers.
if (value1 != value2) {
    double min = Math.min(value1, value2);
    double max = Math.max(value1, value2);
    if ((min < 0) && (max <= 0)) {
        return Math.abs(min) - Math.abs(max);
    } else if ((min >= 0) && (max > 0)) {
        return Math.abs(max) - Math.abs(min);
    } else {
...
double[]range(double[] data, int to, int stride, int numElementsEachStride)
Returns a subset of an array from 0 to "to" using the specified stride
double[] ret = new double[to / stride];
if (ret.length < 1)
    ret = new double[1];
int count = 0;
for (int i = 0; i < data.length; i += stride) {
    for (int j = 0; j < numElementsEachStride; j++) {
        if (i + j >= data.length || count >= ret.length)
            break;
...
doublerange(double[] min, double[] max, double[] min2, double[] max2)
range
if (min == null || max == null || min2 == null || max2 == null) {
    return 0;
double d = 0;
for (int i = 0; i < min.length; i++) {
    d += Math.abs(max[i] - max2[i]) + Math.abs(min[i] - min2[i]);
return d;
...
double[]range(double[] vals)
Get the range of an array.
if (vals.length == 0) {
    return null;
double[] rtn = { vals[0], vals[0] };
for (int i = 1; i < vals.length; i++) {
    if (rtn[0] > vals[i]) {
        rtn[0] = vals[i];
    } else if (rtn[1] < vals[i]) {
...
int[]range(final int max)
Helper function that generates an array of the numbers 0..max-1.
int[] ret = new int[max];
for (int i = 0; i < max; ++i) {
    ret[i] = i;
return ret;
booleanrange(float number, float value, float range)
range
return number > value - range && number < value + range;
int[]range(int begin, int end)
range
int[] ret = new int[Math.abs(end - begin)];
int index = 0;
for (int i = begin; i < end; i++) {
    ret[index] = i;
    index++;
return ret;
int[]range(int end)
range
assert end > 0;
int[] ary = new int[end];
for (int i = 0; i < end; ++i) {
    ary[i] = i;
return ary;
int[]range(int excludedEnd)
range
return range(0, excludedEnd, 1);