ListBinSearch
ssize_t ListBinSearch (ListType listToSearch, const void *pointerToItem, CompareFunction compareFunction);
Purpose
This function searches a list for an item using the binary search algorithm. The time taken by the search is proportional to log base 2 of the number of items in the list.
The list must be in sorted order.
Parameters
Input | ||
Name | Type | Description |
listToSearch | ListType | The list in which to search for the specified item. The binary search algorithm requires that the list be in sorted order. |
pointerToItem | const void * | A pointer to the item for which the list will be searched for a matching item. |
compareFunction | CompareFunction | A comparison function which will be used to compare the specified item to the items in the list. The compare function should have the following prototype: int CVICALLBACK CompareFunction(void *item1, void *item2); The compare function should return a negative number if item1 is less than item2, it should return 0 if item1 is equal to item2, and it should return a positive number is item1 is greater than item2. If zero (0) is passed for the compare function, the C Library function memcmp will be called to compare items. This instrument driver provides several commonly useful comparison functions: ShortCompare IntCompare FloatCompare DoubleCompare CStringCompare CStringNoCaseCompare |
Return Value
Name | Type | Description |
foundPosition | ssize_t | Returns the index of the item in the list whose contents match the specified item. Zero (0) is returned if no matching item is found in the list. |
Additional Information
Library: Programmer's Toolbox
Include file: toolbox\toolbox.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later