Here you can find the source of clamp(int x, int a, int b)
private static int clamp(int x, int a, int b)
//package com.java2s; public class Main { private static int clamp(int x, int a, int b) { return (x < a) ? a : (x > b) ? b : x; }/*from w ww. j av a 2 s . com*/ }