List of utility methods to do Range
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; ... |
boolean | rangeEquals(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; |
boolean | rangeIncludes(long x, long min, long max) range Includes return (min <= x && x <= max);
|
Integer | rangeInteger(Integer num, Integer min, Integer max) range Integer if (num == null) { return num; if (num < min) { num = min; if (num > max) { num = max; ... |
float | rangeLimit(float value, float min, float max) range Limit return max(min(value, max), min);
|
int | rangeLimit(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; |
double | rangeToScale(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); |