public static int binarySearchValueOrLower ( ListNumber values , double value ) { if ( value <= values . getDouble ( 0 ) ) { return 0 ; } if ( value >= values . getDouble ( values . size ( ) - 1 ) ) { return values . size ( ) - 1 ; } int index = binarySearch ( 0 , values . size ( ) - 1 , values , value ) ; while ( index != 0 && value == values . getDouble ( index - 1 ) ) { index -- ; } return index ; }
Finds the value in the list or the one right below it .