Package com.google.mu.collect
Interface BinarySearch.DoubleSearchTarget
- Enclosing class:
BinarySearch
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents the search target that can be found through bisecting the double domain.
-
Method Summary
Modifier and TypeMethodDescriptionint
locate
(double low, double median, double high) Given a range of[low..high]
inclusively withmedian
as the mid point of the binary search, locates the target.
-
Method Details
-
locate
int locate(double low, double median, double high) Given a range of[low..high]
inclusively withmedian
as the mid point of the binary search, locates the target.Returns 0 if
median
is the target; negative to find it in the lower range of[low..median)
; or positive to find it in the upper range of(median..high]
.The
(low, median, high)
parameters are finite values. And it's guaranteed thatlow <= median <= high
.Different from
BinarySearch.IntSearchTarget
andBinarySearch.LongSearchTarget
, the(low, median, high)
parameters don't necessarily split the range in half. Instead,median
is picked such that the number of distinct double precision values in the lower subrange is close to that of the higher subrange.
-