TVecSmallInt::BinarySearch Method

Overload List

#SignatureDescription
1int BinarySearch(const int X);Finds a match for X in object values using binary search.
2int BinarySearch(const int X, const int Index, int Len);
3bool BinarySearch(const int X, int &XIndex);Finds exact or closest index match for X in object values using binary search.
4bool BinarySearch(const int X, int &XIndex, const int Index, int Len);

Overload 1: int BinarySearch(const int X);

Finds a match for X in object values using binary search.

#NameTypeDescription
1Xconst int

Returns: the index of first matched element. If no matching elements are found, the result is -1.

Remarks:

The data in the vector must be sorted in ascending order for this function to work correctly.

Declared in Dew::Math::TMtxVecInt · Dew.Math/AbstractMtxVecInt.h · Cross-compiler

Overload 2: int BinarySearch(const int X, const int Index, int Len);

#NameTypeDescription
1Xconst int
2Indexconst int
3Lenint
Declared in Dew::Math::TMtxVecInt · Dew.Math/AbstractMtxVecInt.h · Cross-compiler

Overload 3: bool BinarySearch(const int X, int &XIndex);

Finds exact or closest index match for X in object values using binary search.

#NameTypeDescription
1Xconst int
2XIndexint &

Returns: True, if found and the index of the next bigger or smaller value in XIndex, if not found.

Remarks:

The data in the vector must be sorted in ascending order for this function to work correctly. The closest match is the index of first bigger or smaller value in the array.

To ensure bigger value write:

Data := [0,2,3];
Data.BinarySearch(Value, XIndex);
if Data[XIndex] > Value then Dec(XIndex);

To ensure smaller value write:

Data := [0,2,3];
Data.BinarySearch(1, XIndex);
if Data[XIndex] < Value then Inc(XIndex);
Declared in Dew::Math::TMtxVecInt · Dew.Math/AbstractMtxVecInt.h · Cross-compiler

Overload 4: bool BinarySearch(const int X, int &XIndex, const int Index, int Len);

#NameTypeDescription
1Xconst int
2XIndexint &
3Indexconst int
4Lenint
Declared in Dew::Math::TMtxVecInt · Dew.Math/AbstractMtxVecInt.h · Cross-compiler