|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.math3.utils.SearchIndexLibrary
public final class SearchIndexLibrary
Index search algorithms based on method BinarySearch, coupled with dichotomy.
Contains two algorithms for both intervals conventions defined by ISearchIndex.SearchIndexIntervalConvention
.
Also contains utility functions.
Method Summary | |
---|---|
static int |
binarySearchClosedOpen(double[] tab,
double key,
int iMin,
int iMax)
Searches the index corresponding to the parameter key inside [tab[iMin], tab[iMax]] with the default convention CLOSED_OPEN, meaning that interval considered are [ tab[i], tab[i+1] [ and therefore, if x = tab[i], the integer returned is i. |
static int |
binarySearchOpenClosed(double[] tab,
double key,
int iMin,
int iMax)
Searches the index corresponding to the parameter key inside [tab[iMin], tab[iMax]] with the convention OPEN_CLOSED, meaning that interval considered are ] tab[i], tab[i+1] ] and therefore, if x = tab[i], the integer returned is i-1. |
static int |
midPoint(int iMin,
int iMax)
Returns the index of a middle point of segment [iMin, iMax] |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static int midPoint(int iMin, int iMax)
iMin
- : the lower bound of the intervaliMax
- : the upper bound of the interval
public static int binarySearchClosedOpen(double[] tab, double key, int iMin, int iMax)
tab
- : the double[] already sorted.key
- : the double searched inside [tab[iMin], tab[iMax]]iMin
- : the lower bound of tab considered. If key < tab[iMin], the integer returned is iMin - 1iMax
- : the lower bound of tab considered. If key >=tab[iMax], the integer returned is iMax.
As a consequence, a method using an index returned by binarySearchClosedOpen should consider two behavior
if index = iMax. It can be either key = tab[iMax] or key > tab[iMax].
public static int binarySearchOpenClosed(double[] tab, double key, int iMin, int iMax)
tab
- : the double[] already sorted.key
- : the double searched inside [tab[iMin], tab[iMax]]iMin
- : the lower bound of tab considered. If key <= tab[iMin], the integer returned is iMin - 1iMax
- : the lower bound of tab considered. If key > tab[iMax], the integer returned is iMax.
As a consequence, a method using an index returned by binarySearchClosedOpen should consider two behavior
if index = iMin - 1. It can be either key = tab[iMin] or key < tab[iMin]
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |