public class BinarySearchIndexClosedOpen 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 sorting, no exception will be thrown, but the results can be totally wrong.
The interval convention is set toISearchIndex.SearchIndexIntervalConvention.CLOSED_OPEN
.ISearchIndex.SearchIndexIntervalConvention
convention, iMax, iMin, tab
Constructor and Description |
---|
BinarySearchIndexClosedOpen(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.CLOSED_OPEN . |
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.CLOSED_OPEN . |
getConvention, getTab
public BinarySearchIndexClosedOpen(double[] tab2)
tab2
- : a double[] array sorted by increasing order. Duplicates are allowed.public int getIndex(double x)
ISearchIndex.SearchIndexIntervalConvention.CLOSED_OPEN
.x
- : the value to search.public int getIndex(double x, int iMin2, int iMax2)
ISearchIndex.SearchIndexIntervalConvention.CLOSED_OPEN
.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 © 2021 CNES. All rights reserved.