Index<T>.Lookup Nearest Method
Definition
Namespace: Numerics.NET.DataAnalysis
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.3
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.3
Overload List
Lookup | Maps a sequence of keys to the position of the nearest key in the index. |
Lookup | 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.
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.
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
Int32If 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
Invalid | The index is not sorted. |