public static int binarySearchCeil(long[] a,long key,boolean inclusive,boolean stayInBounds){
  int index=Arrays.binarySearch(a,key);
  index=index < 0 ? ~index : (inclusive ? index : (index + 1));
  return stayInBounds ? Math.min(a.length - 1,index) : index;
}

public static int binarySearchCeil ( long [ ] a , long key , boolean inclusive , boolean stayInBounds ) { int index = Arrays . binarySearch ( a , key ) ; index = index < 0 ? ~ index : ( inclusive ? index : ( index + 1 ) ) ; return stayInBounds ? Math . min ( a . length - 1 , index ) : index ; }
returns the index of the smallest value in an array that is greater than ( or optionally equal to ) a specified key . < p > the search is performed using a binary search algorithm , and so the array must be sorted .
