nag_search_char (m01ncc) examines an ordered vector of null terminated strings and returns the index of the first value equal to the sought-after item. Character items are compared according to the ASCII collating sequence.
nag_search_char (m01ncc) is based on Professor Niklaus Wirth's implementation of the Binary Search algorithm (see
Wirth (2004)), but with two modifications. First, if the sought-after item is less than the value of the first element of the array to be searched,
is returned. Second, if a value equal to the sought-after item is not found, the index of the immediate lower value is returned.
Not applicable.
nag_search_char (m01ncc) is not threaded in any implementation.
The argument
validate should be used with caution. Set it to Nag_FALSE only if you are confident that the other arguments are correct, in particular that array
ch is in fact arranged in ascending order. If you wish to search the same array
ch many times, you are recommended to set
validate to Nag_TRUE on first call of nag_search_char (m01ncc) and to Nag_FALSE on subsequent calls, in order to minimize the amount of time spent checking
ch, which may be significant if
ch is large.
This example reads a list of character data and sought-after items and performs the search for these items.