org.apache.commons.math3.utils
Interface ISearchIndex

All Known Implementing Classes:
AbstractSearchIndex, BinarySearchIndexClosedOpen, BinarySearchIndexOpenClosed, RecordSegmentSearchIndex

public interface ISearchIndex

Interfaces for optimized indices search algorithm.

Each class that implements this interface will have at least two constructors : - one with a double[] as a parameter and an enumerate SearchIndexIntervalConvention - one with a double[] as a parameter. In that case, the enumerate SearchIndexIntervalConvention is set to CLOSED_OPEN by default.

IMPORTANT: the input double[] should already be sorted by increasing order. If this input tab is not sorted, no exception will be thrown, but the results can be totally wrong. Duplicates are allowed.

The input double[] should not be modified by the interface implementations.

The enumerate ISearchIndex.SearchIndexIntervalConvention defines the implementing of the method getIndex that should respect the following convention :

CLOSED_OPEN (default case) OPEN_CLOSED

Since:
2.3.1
Version:
$Id: ISearchIndex.java 17583 2017-05-10 13:05:10Z bignon $
Author:
Sophie Laurens

Nested Class Summary
static class ISearchIndex.SearchIndexIntervalConvention
          Describes the shape of an interval.
 
Method Summary
 ISearchIndex.SearchIndexIntervalConvention getConvention()
          Returns the convention that can be applied to the interval during the search index algorithm.
 int getIndex(double x)
          Returns the index of x in a tab depending on the convention used.
 int getIndex(double x, int iMin, int iMax)
          Returns the index of x in the extracted tab [tab[iMin], tab[iMax]] depending on the convention used.
 double[] getTab()
          Returns the array of values.
 

Method Detail

getIndex

int getIndex(double x)
Returns the index of x in a tab depending on the convention used.
Therefore no exception is returned even if x does not belong to [tab[0], tab[numberOfPoints - 1] ]

Parameters:
x - : the value to search.
Returns:
the corresponding index, see the above conditions.
Preconditions :
: tab is already sorted by increasing order. Duplicates are allowed.

getIndex

int getIndex(double x,
             int iMin,
             int iMax)
Returns the index of x in the extracted tab [tab[iMin], tab[iMax]] depending on the convention used.

Parameters:
x - : the value to search.
iMin - : defines the lower bound of the tab for the search.
iMax - : defines the upper bound of the tab for the search.
Returns:
the corresponding index, see the above conditions.
Preconditions :
: tab is already sorted by increasing order. Duplicates are allowed.

getConvention

ISearchIndex.SearchIndexIntervalConvention getConvention()
Returns the convention that can be applied to the interval during the search index algorithm. Describes the boundaries of each interval defined by tab.

Returns:
CLOSED_OPEN if intervals are [tab[i], tab[i+1][ or OPEN_CLOSED for ]tab[i], tab[i+1]].

getTab

double[] getTab()
Returns the array of values.

Returns:
tab


Copyright © 2017 CNES. All Rights Reserved.