CFArrayBSearchValues(_:_:_:_:_:)
Searches an array for a value using a binary search algorithm.
Declaration
func CFArrayBSearchValues(_ theArray: CFArray!, _ range: CFRange, _ value: UnsafeRawPointer!, _ comparator: CFComparatorFunction!, _ context: UnsafeMutableRawPointer!) -> CFIndexParameters
- theArray:
An array, sorted from least to greatest according to the
comparatorfunction. - range:
The range within
theArrayto search. The range must not exceed the bounds oftheArray. The range may be empty (length0). - value:
The value for which to find a match in
theArray. Ifvalue, or any other value intheArray, is not understood by thecomparatorcallback, the behavior is undefined. - comparator:
The function with the comparator function type signature that is used in the binary search operation to compare values in
theArraywith the given value. If there are values in the range that thecomparatorfunction does not expect or cannot properly compare, the behavior is undefined. - context:
A pointer-sized program-defined value, which is passed as the third argument to the
comparatorfunction, but is otherwise unused by this function. If the context is not what is expected by thecomparatorfunction, the behavior is undefined.
Return Value
The return value is one of the following:
Discussion
The index of a value that matched, if the target value matches one or more in the range.
Greater than or equal to the end point of the range, if the value is greater than all the values in the range.
The index of the value greater than the target value, if the value lies between two of (or less than all of) the values in the range.