public class GenericInequalitySearch extends Object
In order to make the searching unique and unambiguous, we modified the traditional binary search algorithm to search for adjacent pairs of values {A, B} in the values array instead of just a single value, where A and B are the array indicies of two adjacent values in the array. We then define the searching criteria, given an array of values arr[] and the search key value v, as follows:
Modifier and Type | Class and Description |
---|---|
static class |
GenericInequalitySearch.Inequality
The enumerator of inequalities
|
Constructor and Description |
---|
GenericInequalitySearch()
Constructs this class
|
Modifier and Type | Method and Description |
---|---|
static <T> int |
find(T[] arr,
int low,
int high,
T v,
GenericInequalitySearch.Inequality inequality,
Comparator<T> comparator)
Binary Search for the index of the generic value in the given search range that satisfies
the given inequality.
|
public static <T> int find(T[] arr, int low, int high, T v, GenericInequalitySearch.Inequality inequality, Comparator<T> comparator)
T
- The generic type of value to be used in the search process.arr
- the given array that must be sorted.low
- the index of the lowest value in the search rangehigh
- the index of the highest value in the search rangev
- the value to search for.inequality
- one of LT, LE, EQ, GE, GTcomparator
- for the type TCopyright © 2015–2021 The Apache Software Foundation. All rights reserved.