Alternate Entry Name: _INDEX
B: idx = .index(vec, num, value [, delta, term, cmpinst, mask]);
C: int _index(void *vec, int num, int value, [ int delta, int term, int cmpinst, int mask] );
vec[0] vec[delta] ... vec[(num-1)*delta]
If "delta" is omitted, the default is 1.
.INDEX lets you perform fast linear searches using repeat instructions. By selecting different termination conditions and compare instructions, you can perform a wide variety of linear searches. The default is simply to search linearly through a vector for the first exact match of a value. .INDEX compensates for the overrun implicit in the RPT instruction, so if a match is found "vec[idx]" is the value that matched.
Although .INDEX is quite flexible, it is not a perfectly generalized linear search. There are a number of hardware-imposed restrictions. You can only search increasing memory addresses, "delta" cannot exceed 63, and the potential search address "vec[(num-1)*delta]" must exist within your program even when an actual match value exists. C programmers in particular should be aware that use of more than the first four arguments will be non-portable, and should be "hidden" with a less general "cover" function or macro.
Copyright © 1996, Thinkage Ltd.