ChartDirector 5.1 (.NET Edition)

Chart.bSearch


Usage

[VB] Public Shared Function bSearch(a As Array, v As Object) As Double
[C#] public static double bSearch(Array a, Object v);

Description

Uses binary search to search for a value in an array.

This method returns the array index of the value in the array, which must be sorted in ascending order.

If the value is in between two elements of the array, this method returns a non-integer that interpolates the indexes of the two elements. For example, suppose the array consists of 3 elements [4, 6, 10]. If this method is used to search for the value 7, it will return 1.25.

If the value is smaller or larger than all the elements in the array, this method returns the nearest index, which must be either 0 or the index of the last element of the array.

Arguments

ArgumentDefaultDescription
a(Mandatory)The array to be searched.
v(Mandatory)The value to search for.

Return Value

The index of the value within the array. If the value is in between two elements of the array, this method returns a non-integer that interpolates the indexes of the two elements. If the value is smaller or larger than all the elements in the array, thie method returns the nearest index.