TVec::BinarySearch Method

Overload List

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

Overload 1: int BinarySearch(const double x);

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

#NameTypeDescription
1xconst double

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::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

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

#NameTypeDescription
1xconst double
2Indexconst int
3Lenint
Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 3: int BinarySearch(const TCplx &x);

#NameTypeDescription
1xconst TCplx &
Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 4: int BinarySearch(const TCplx &x, const int Index, int Len);

#NameTypeDescription
1xconst TCplx &
2Indexconst int
3Lenint
Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 5: bool BinarySearch(const double x, int &XIndex);

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

#NameTypeDescription
1xconst double
2XIndexint &

Returns: True and exact index in XIndex, if found and False 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::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 6: bool BinarySearch(const double x, int &XIndex, const int Index, int Len);

#NameTypeDescription
1xconst double
2XIndexint &
3Indexconst int
4Lenint
Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 7: bool BinarySearch(const TCplx &x, int &XIndex);

#NameTypeDescription
1xconst TCplx &
2XIndexint &
Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 8: bool BinarySearch(const TCplx &x, int &XIndex, const int Index, int Len);

#NameTypeDescription
1xconst TCplx &
2XIndexint &
3Indexconst int
4Lenint
Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler