org.apache.commons.math3.utils
Class AbstractSearchIndex

java.lang.Object
  extended by org.apache.commons.math3.utils.AbstractSearchIndex
All Implemented Interfaces:
ISearchIndex
Direct Known Subclasses:
BinarySearchIndexClosedOpen, BinarySearchIndexOpenClosed, RecordSegmentSearchIndex

public abstract class AbstractSearchIndex
extends Object
implements ISearchIndex

Abstract class for index search algorithm 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.

Each implementation of this class defines a convention of SearchIndexIntervalConvention.

Since:
2.3.1
Version:
$Id: AbstractSearchIndex.java 13046 2015-04-27 15:11:21Z bignon $
Author:
Sophie Laurens
Concurrency :
not thread-safe

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.commons.math3.utils.ISearchIndex
ISearchIndex.SearchIndexIntervalConvention
 
Field Summary
protected  ISearchIndex.SearchIndexIntervalConvention convention
          The convention for the definition of intervals.
protected  int iMax
          The upper bound of tab to consider for the search index algorithm.
protected  int iMin
          The lower bound of tab to consider for the search index algorithm.
protected  double[] tab
          The values in with the search algorithm will be executed.
 
Constructor Summary
AbstractSearchIndex(double[] tab2)
          Default constructor with default CLOSED_OPEN convention.
AbstractSearchIndex(double[] tab2, ISearchIndex.SearchIndexIntervalConvention searchIndexConvention)
          Constructor with defined interval convention.
 
Method Summary
 ISearchIndex.SearchIndexIntervalConvention getConvention()
          Returns the convention that can be applied to the interval during the search index algorithm.
 double[] getTab()
          Returns the array of values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.math3.utils.ISearchIndex
getIndex, getIndex
 

Field Detail

tab

protected double[] tab
The values in with the search algorithm will be executed.


iMin

protected int iMin
The lower bound of tab to consider for the search index algorithm. By default, iMin = 0.


iMax

protected int iMax
The upper bound of tab to consider for the search index algorithm. By default, iMax = tab.length - 1.


convention

protected ISearchIndex.SearchIndexIntervalConvention convention
The convention for the definition of intervals.

Constructor Detail

AbstractSearchIndex

public AbstractSearchIndex(double[] tab2)
Default constructor with default CLOSED_OPEN convention.

Parameters:
tab2 - : a double[] array sorted by increasing order. Duplicates are allowed.
Preconditions :
: tab is already sorted by increasing order. Duplicates are allowed.

AbstractSearchIndex

public AbstractSearchIndex(double[] tab2,
                           ISearchIndex.SearchIndexIntervalConvention searchIndexConvention)
Constructor with defined interval convention.

Parameters:
tab2 - : a sorted double[]
searchIndexConvention - interval convention
Preconditions :
: tab is already sorted by increasing order. Duplicates are allowed.
Method Detail

getTab

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

Specified by:
getTab in interface ISearchIndex
Returns:
tab

getConvention

public 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.

Specified by:
getConvention in interface ISearchIndex
Returns:
CLOSED_OPEN if intervals are [tab[i], tab[i+1][ or OPEN_CLOSED for ]tab[i], tab[i+1]].


Copyright © 2016 CNES. All Rights Reserved.