org.apache.commons.math3.utils
Class BinarySearchIndexClosedOpen
java.lang.Object
org.apache.commons.math3.utils.AbstractSearchIndex
org.apache.commons.math3.utils.BinarySearchIndexClosedOpen
- All Implemented Interfaces:
- ISearchIndex
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 to ISearchIndex.SearchIndexIntervalConvention.CLOSED_OPEN
.
- Since:
- 2.3.1
- Version:
- $Id: BinarySearchIndexClosedOpen.java 12338 2015-02-12 15:38:38Z maggiorani $
- Author:
- Sophie Laurens
- Concurrency :
- immutable
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BinarySearchIndexClosedOpen
public BinarySearchIndexClosedOpen(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.CLOSED_OPEN
.
- 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.CLOSED_OPEN
.
- 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.