public class BinarySearchIndexOpenClosed extends AbstractSearchIndex
Searches index in a double[] with a coupled dichotomy-BinarySearch algorithms.
IMPORTANT: the tab passed in the constructor has to be sorted by increasing order. Duplicates are allowed. If this tab is not sorted, no exception will be thrown, but the results can be totally wrong.
The interval convention is set toISearchIndex.SearchIndexIntervalConvention.OPEN_CLOSED
.ISearchIndex.SearchIndexIntervalConvention
convention, iMax, iMin, tab
Constructor and Description |
---|
BinarySearchIndexOpenClosed(double[] tab2)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getIndex(double x)
Returns the index of x in a tab with a dichotomy / BinarySearch algorithm under
the convention
ISearchIndex.SearchIndexIntervalConvention.OPEN_CLOSED . |
int |
getIndex(double x,
int iMin2,
int iMax2)
Returns the index of x in a tab with a dichotomy / BinarySearch algorithm under
the convention
ISearchIndex.SearchIndexIntervalConvention.OPEN_CLOSED . |
getConvention, getTab
public BinarySearchIndexOpenClosed(double[] tab2)
tab2
- : a double[] array sorted by increasing order. Duplicates are allowed.public int getIndex(double x)
ISearchIndex.SearchIndexIntervalConvention.OPEN_CLOSED
.x
- : the value to search.public int getIndex(double x, int iMin2, int iMax2)
ISearchIndex.SearchIndexIntervalConvention.OPEN_CLOSED
.x
- : the value to search.iMin2
- : defines the lower index bound of the tab for the search.iMax2
- : defines the upper index bound of the tab for the search.Copyright © 2023 CNES. All rights reserved.