List of utility methods to do Integer Clamp
int | clamp(final int min, final int x, final int max) Clamps the value 'x' to be in the range [min, max]. if (max < min) { throw new IllegalArgumentException("Max is less than min"); return Math.max(min, Math.min(max, x)); |
int | clamp(final int value, final int min, final int max) clamp return Math.min(Math.max(value, min), max);
|
int | clamp(final int value, final int min, final int max) clamp if (Integer.compare(value, min) < 0) { return min; if (Integer.compare(value, max) > 0) { return max; return value; |
int | clamp(int a) clamp if (a < 0) { return 0; } else if (a > 0xff) { return 0xff; return a; |
int | clamp(int a, int x, int b) Clamps the value between two endpoints. if (x < a) { return a; } else if (x > b) { return b; } else { return x; |
int | clamp(int a, int x, int y) clamp if (x > y) { int m = x; y = x; x = m; return Math.max(x, Math.min(y, a)); |
int | clamp(int amt, int low, int high) Constrains a value to not exceed a maximum and minimum value. return (amt < low) ? low : ((amt > high) ? high : amt);
|
int | clamp(int c) Clamp a value to range 0..255. if (c < 0) { return 0; if (c > 255) { return 255; return c; |
int | clamp(int c) Clamp a value to the range 0..255 if (c < 0) return 0; if (c > 255) return 255; return c; |
int | clamp(int floor, int ceiling, int value) clamp return Math.min(ceiling, Math.max(floor, value));
|