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 indices 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.
| Modifier and Type | Class and Description |
|---|---|
static class |
GenericInequalitySearch.Inequality
The enumerator of inequalities
|
| Constructor and Description |
|---|
GenericInequalitySearch() |
| 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 with increasing values, must not be null,
and must not contain null values in the given range {low, high} inclusive.low - the lowest index of the lowest value in the search range, inclusive.high - the highest index of the highest value in the search range, inclusive.v - the value to search for. It must not be null.inequality - one of LT, LE, EQ, GE, GT. It must not be null.comparator - for the type T. It must not be null.Copyright © 2015–2020 The Apache Software Foundation. All rights reserved.