Java Utililty Methods Range

List of utility methods to do Range

Description

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

Method

Integer[][]rangeDivide(Integer begin, Integer end, Integer divideNum)
range Divide
if (begin == null || end == null || begin >= end || divideNum == null || divideNum <= 0) {
    return null;
Integer[][] ranges = new Integer[divideNum][2];
int spread = end - begin;
for (int i = 1; i < divideNum; i++) {
    ranges[i - 1][0] = spread / divideNum * (i - 1) + begin;
    ranges[i - 1][1] = spread / divideNum * i + begin;
...
booleanrangeEquals(byte[] a, int aStart, byte[] b, int bStart, int length)
range Equals
assert a.length - aStart > length && b.length - bStart > length;
for (int i = aStart, j = bStart, k = 0; k < length; k++) {
    if (a[i] != b[j])
        return false;
return true;
booleanrangeIncludes(long x, long min, long max)
range Includes
return (min <= x && x <= max);
IntegerrangeInteger(Integer num, Integer min, Integer max)
range Integer
if (num == null) {
    return num;
if (num < min) {
    num = min;
if (num > max) {
    num = max;
...
floatrangeLimit(float value, float min, float max)
range Limit
return max(min(value, max), min);
intrangeLimit(int receiver, int minBound, int maxBound)
range Limit
if (receiver < minBound)
    return minBound;
else if (receiver > maxBound)
    return maxBound;
else
    return receiver;
byte[]rangeOfByteArray(byte[] data, int offset, int length)
range Of Byte Array
byte[] buffer = new byte[length];
for (int a = 0; a < length; a++, offset++) {
    buffer[a] = data[offset];
return buffer;
doublerangeToScale(long rawValue, long rangeMin, long rangeMax, double scaleMin, double scaleMax)
range To Scale
final double multiplier = (scaleMax - scaleMin) / (rangeMax - rangeMin);
final double devValue = multiplier * (rawValue - rangeMin) + scaleMin;
return fitInRange(devValue, scaleMin, scaleMax);