Index<T>.LookupNearest Method

Definition

Namespace: Extreme.DataAnalysis
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23

Overload List

LookupNearest(IEnumerable<T>, Direction) Maps a sequence of keys to the position of the nearest key in the index.
LookupNearest(T, Direction) Finds the key nearest to the specified value in the index.

LookupNearest(IEnumerable<T>, Direction)

Maps a sequence of keys to the position of the nearest key in the index.
C#
public virtual int[] LookupNearest(
	IEnumerable<T> values,
	Direction direction
)

Parameters

values  IEnumerable<T>
A sequence of keys to locate in the index.
direction  Direction
The direction to look for the key if an exact match is not found.

Return Value

Int32[]
An array containing the mapped position of the elements of values. If a nearest key was found in the index, then the mapped position is the zero-based position of the first occurance of the value in the index; otherwise the mapped position is -1.

LookupNearest(T, Direction)

Finds the key nearest to the specified value in the index.
C#
public int LookupNearest(
	T key,
	Direction direction
)

Parameters

key  T
The key to locate.
direction  Direction
The direction to look for the key if an exact match is not found.

Return Value

Int32
If a key was found, the zero-based position of the key closest to key in the direction specified by direction; otherwise -1.

Remarks

This operation is only allowed on sorted indexes.

The only situation where a lookup can fail is if key is smaller than the first key (if direction is Forward) or greater than the last key (if direction is Backward).

Exceptions

InvalidOperationExceptionThe index is not sorted.

See Also