Click or drag to resize

Functions.AScanBinExact Method

Scan a sorted array until there is an exact match or a code block returns 0.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.16
 FUNCTION AScanBinExact(
	aTarget AS ARRAY,
	uSearch AS USUAL
Request Example View Source


Type: Array
The sorted array to scan.
Type: Usual
The value to scan for.
Unless this argument is a code block, it must match the data type of the elements in aTarget.
If uSearch is a code block, it should return a numeric value that indicates the outcome of the comparison: a positive value indicates that uSearch is greater than the current array element, a 0 stands for equality, and a negative value indicates that uSearch is less than the current array element.

Return Value

Type: DWord
If uSearch is a code block, AScanBinExact() returns the position of the element if the code block returned 0.
Otherwise, AScanBinExact() returns the position of an exact-matching element.
If multiple occurrences of the same element exist, the returned exact match is not necessarily the lowest numbered element since AScanBinExact() uses a binary search algorithm.
AScanBinExact() returns 0 if no exact match is found.
AScanBinExact() is the same as AScanBin() except that == is used for matching instead of =.
This example shows the difference between AScanBinExact() and AScanBin():
1aArray := {"Larger", "Largest"}    // Already sorted
2? "Larger" = "Large"            // TRUE
3? "Larger" == "Large"            // FALSE
4? AScanBin(aArray, "Large")        // 1
5? AScanBinExact(aArray, "Large")    // 0
See Also