binarySearch

binarySearch(search: Integer;
             index:  Integer io): Boolean;

The binarySearch method of the IntegerArray class sets the index parameter to the position in the array of the element specified in the search parameter if found or to the position at which it should be added if it does not exist.

This method returns true if another specified element is located. If no element is found, this method returns false and places the position in the array at which the element should be added in the index parameter.

The code fragment in the following example shows the use of the binarySearch method.

if not rowPositions.includes(top) then
    rowPositions.binarySearch(top, pos);
    rowPositions.insert(pos + 1, top);
endif;

Use the binarySearch64 method instead of the binarySearch method, if the number of entries in the array could exceed the maximum integer value of 2,147,483,647.