The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....


Class: TVector, TIntVector
Declaration: function FindInSortedVector (Ascending: boolean; Value: double): integer; { class TVector }
function FindInSortedVector (Ascending: boolean; Value: integer): integer; { class TIntVector }

The function FindInSortedVector searches the sorted vector for the element which is closest to Value and returns the index of the found element as the function value. The parameter Ascending indicates the sort order of the vector elements (TRUE = ascending, FALSE = descending).

Hint: As opposed to Find, the search algorithm in FindInSortedVector is based on a binary search, which is considerably faster, but which requires the vector to be sorted. If the vector elements are not sorted or not sorted according to the parameter Ascending, the search will not succeed, even if there is a matching cell in the vector.

Last Update: 2014-Sep-14