Java Integer Clamp clamp(int value, int low, int high)

Here you can find the source of clamp(int value, int low, int high)

Description

clamp

License

Open Source License

Declaration

private static int clamp(int value, int low, int high) 

Method Source Code

//package com.java2s;
/*/*from  w  ww  .j  a v  a2  s  .  c om*/
 * ColorUtil.java
 *
 * Copyright (C) 2009-12 by RStudio, Inc.
 *
 * Unless you have received this program directly from RStudio pursuant
 * to the terms of a commercial license agreement with RStudio, then
 * this program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

public class Main {
    private static double clamp(double value, double low, double high) {
        if (value < low)
            return low;
        else if (value > high)
            return high;
        return value;
    }

    private static int clamp(int value, int low, int high) {
        return (int) clamp((double) value, (double) low, (double) high);
    }
}

Related

  1. clamp(int v, int min, int max)
  2. clamp(int v, int min, int max)
  3. clamp(int val, int min, int max)
  4. clamp(int value, final int minimum, final int maximum)
  5. clamp(int value, int a, int b)
  6. clamp(int value, int low, int high)
  7. clamp(int value, int min, int max)
  8. clamp(int value, int min, int max)
  9. clamp(int value, int min, int max)