4.3BSD-Reno/share/man/cat3/lsearch.0
LSEARCH(3) 1990 LSEARCH(3)
NNAAMMEE
lsearch, lfind, - linear searching routines
SSYYNNOOPPSSIISS
cchhaarr **
llsseeaarrcchh((ccoonnsstt vvooiidd **kkeeyy,, ccoonnsstt vvooiidd **bbaassee,,
ssiizzee__tt **nneellpp,, ssiizzee__tt wwiiddtthh,,
iinntt ((**ccoommppaarr)) ((vvooiidd **,, vvooiidd **))));;
cchhaarr **
llffiinndd((ccoonnsstt vvooiidd **kkeeyy,, ccoonnsstt vvooiidd **bbaassee,,
ssiizzee__tt **nneellpp,, ssiizzee__tt wwiiddtthh,,
iinntt ((**ccoommppaarr)) ((vvooiidd **,, vvooiidd **))));;
DDEESSCCRRIIPPTTIIOONN
TThhiiss iinntteerrffaaccee wwaass oobbssoolleettee bbeeffoorree iitt wwaass wwrriitttteenn.. IItt iiss
aavvaaiillaabbllee ffrroomm tthhee ccoommppaattiibbiilliittyy lliibbrraarryy,, lliibbccoommppaatt..
The functions _l_s_e_a_r_c_h, and _l_f_i_n_d provide basic linear
searching functionality.
_B_a_s_e is the pointer to the beginning of an array. _N_e_l_p is
the current number of elements in the array, where each ele-
ment is _w_i_d_t_h bytes long. _C_o_m_p_a_r is a comparison routine
which is used to compare two elements. It is called with
two arguments that point to the _k_e_y object and to an array
member, in that order, and must return an integer less than,
equal to, or greater than zero if the _k_e_y object is con-
sidered, respectively, to be less than, equal to, or greater
than the array member.
_L_s_e_a_r_c_h and _l_f_i_n_d return a pointer into the array referenced
by _b_a_s_e where _k_e_y is located. If _k_e_y does not exist, _l_f_i_n_d
will return a NULL pointer and _l_s_e_a_r_c_h will add it to the
array. When an element is added to the array by _l_s_e_a_r_c_h the
location referenced by the argument _n_e_l_p is incremented by
one.
SSEEEE AALLSSOO
bsearch(3), hsearch(3), tsearch(3)
Printed 7/27/90 June 1