Java Utililty Methods Integer Clamp

List of utility methods to do Integer Clamp

Description

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

Method

intclamp(int ptr, int size)
clamp
return clamp(ptr, 0, size - 1);
intclamp(int v, int min, int max)
clamp
if (v < min)
    v = min;
if (v > max)
    v = max;
return v;
intclamp(int v, int min, int max)
clamp
return Math.max(Math.min(v, max), min);
intclamp(int v, int min, int max)
Clamps the specified value into the given range.
return (v < min ? min : (v > max ? max : v));
intclamp(int val, int min, int max)
clamp
val = Math.min(val, max);
val = Math.max(val, min);
return val;
intclamp(int value, final int minimum, final int maximum)
clamp
if (minimum > maximum) {
    throw new IllegalArgumentException(
            "The minimum " + minimum + " is larger than the maximum " + maximum + ", possible bug?");
if (value < minimum) {
    value = minimum;
} else if (value > maximum) {
    value = maximum;
...
intclamp(int value, int a, int b)
Returns the passed in value if it resides within the specified range (inclusive).
int min = (a > b) ? b : a;
int max = (a > b) ? a : b;
if (value < min)
    value = min;
else if (value > max)
    value = max;
return value;
intclamp(int value, int low, int high)
clamp
return (int) clamp((double) value, (double) low, (double) high);
intclamp(int value, int low, int high)
Clamps the supplied value to between low and high (both inclusive).
if (value < low)
    return low;
if (value > high)
    return high;
return value;
intclamp(int value, int min, int max)
Ensures that a values does not leave a range.
return Math.min(Math.max(value, min), max);