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.

@FunctionalInterface public static interface BinarySearch.DoubleSearchTarget
Represents the search target that can be found through bisecting the double domain.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    locate(double low, double median, double high)
    Given a range of [low..high] inclusively with median 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 with median 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 that low <= median <= high.

      Different from BinarySearch.IntSearchTarget and BinarySearch.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.