Class BinarySearch
- java.lang.Object
-
- org.apache.datasketches.quantilescommon.BinarySearch
-
public final class BinarySearch extends Object
Contains common equality binary search algorithms.- Author:
- Lee Rhodes
-
-
Constructor Summary
Constructors Constructor Description BinarySearch()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
find(double[] arr, int low, int high, double v)
Binary Search for the index of the exact double value in the given search range.static int
find(float[] arr, int low, int high, float v)
Binary Search for the index of the exact float value in the given search range.static int
find(long[] arr, int low, int high, long v)
Binary Search for the index of the exact long value in the given search range.
-
-
-
Method Detail
-
find
public static int find(float[] arr, int low, int high, float v)
Binary Search for the index of the exact float value in the given search range. If -1 is returned there are no values in the search range that equals the given value.- Parameters:
arr
- The given ordered array to search.low
- the index of the lowest value of the search rangehigh
- the index of the highest value of the search rangev
- the value to search for- Returns:
- return the index of the value, if found, otherwise, return -1;
-
find
public static int find(double[] arr, int low, int high, double v)
Binary Search for the index of the exact double value in the given search range. If -1 is returned there are no values in the search range that equals the given value.- Parameters:
arr
- The given ordered array to search.low
- the index of the lowest value of the search rangehigh
- the index of the highest value of the search rangev
- the value to search for- Returns:
- return the index of the value, if found, otherwise, return -1;
-
find
public static int find(long[] arr, int low, int high, long v)
Binary Search for the index of the exact long value in the given search range. If -1 is returned there are no values in the search range that equals the given value.- Parameters:
arr
- The given ordered array to search.low
- the index of the lowest value of the search rangehigh
- the index of the highest value of the search rangev
- the value to search for- Returns:
- return the index of the value, if found, otherwise, return -1;
-
-