com.mindprod.common11
Class Limiter

java.lang.Object
  extended by com.mindprod.common11.Limiter

public final class Limiter
extends java.lang.Object

Simple methods to corral values into bounds.

Since:
1997
Version:
1.6 2005-07-14
Author:
Roedy Green, Canadian Mind Products

Method Summary
static int cap(int v, int high)
          Caps the max value, ensuring it does not go too high.
static int corral(int v, int low, int high)
          Corrals a value back into safe bounds.
static int hem(int v, int low)
          Ensures a value does not go too low.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cap

public static int cap(int v,
                      int high)
Caps the max value, ensuring it does not go too high. alias for min.

Parameters:
v - the value
high - the high bound above which v cannot go.
Returns:
the lesser of v and high.
See Also:
Math.min(int,int)

corral

public static int corral(int v,
                         int low,
                         int high)
Corrals a value back into safe bounds.

Parameters:
v - the value
low - the low bound below which v cannot go.
high - the high bound above which v cannot go.
Returns:
low if v < low, high if v > high, but normally just v.

hem

public static int hem(int v,
                      int low)
Ensures a value does not go too low. alias for max

Parameters:
v - the value
low - the low bound below which v cannot go.
Returns:
the greater of v and low.
See Also:
Math.max(int,int)