private int findInsertion ( float depth ) { int low = 0 , high = children . size ( ) - 1 ; while ( low <= high ) { int mid = ( low + high ) >>> 1 ; float midDepth = children . get ( mid ) . depth ( ) ; if ( depth > midDepth ) { low = mid + 1 ; } else if ( depth < midDepth ) { high = mid - 1 ; } else { return mid ; } } return low ; }
who says you never have to write binary search?