public static <T>int binarySearchFloor(List<? extends Comparable<? super T>> list,T key,boolean inclusive,boolean stayInBounds){
  int index=Collections.binarySearch(list,key);
  index=index < 0 ? -(index + 2) : (inclusive ? index : (index - 1));
  return stayInBounds ? Math.max(0,index) : index;
}

public static < T > int binarySearchFloor ( List < ? extends Comparable < ? super T > > list , T key , boolean inclusive , boolean stayInBounds ) { int index = Collections . binarySearch ( list , key ) ; index = index < 0 ? - ( index + 2 ) : ( inclusive ? index : ( index - 1 ) ) ; return stayInBounds ? Math . max ( 0 , index ) : index ; }
returns the index of the largest value in an list that is less than ( or optionally equal to ) a specified key . < p > the search is performed using a binary search algorithm , and so the list must be sorted .
