org.apache.commons.math3.utils
Class BinarySearchIndexOpenClosed
java.lang.Object
org.apache.commons.math3.utils.AbstractSearchIndex
org.apache.commons.math3.utils.BinarySearchIndexOpenClosed
- All Implemented Interfaces:
- ISearchIndex
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 to ISearchIndex.SearchIndexIntervalConvention.OPEN_CLOSED
.
- Since:
- 2.3.1
- Version:
- $Id: BinarySearchIndexOpenClosed.java 13087 2015-04-29 09:59:07Z maggiorani $
- Author:
- Sophie Laurens
- Concurrency :
- immutable
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BinarySearchIndexOpenClosed
public BinarySearchIndexOpenClosed(double[] tab2)
- Constructor.
- Parameters:
tab2
- : a double[] array sorted by increasing order. Duplicates are allowed.
getIndex
public int getIndex(double x)
- Returns the index of x in a tab with a dichotomy / BinarySearch algorithm under
the convention
ISearchIndex.SearchIndexIntervalConvention.OPEN_CLOSED
.
- Parameters:
x
- : the value to search.
- Returns:
- index of value that belongs to [0, numberOfPoints-1] that fits the above conditions.
getIndex
public 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
.
- Parameters:
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.
- Returns:
- index of value that belongs to [iMin2, iMax2] that fits the above conditions.
Copyright © 2016 CNES. All Rights Reserved.