home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
gnu
/
man
/
cat3
/
bsearch.0
< prev
next >
Wrap
Text File
|
1993-12-07
|
2KB
|
67 lines
BSEARCH(3) UNIX Programmer's Manual BSEARCH(3)
NNAAMMEE
bbsseeaarrcchh - binary search of a sorted table
SSYYNNOOPPSSIISS
##iinncclluuddee <<ssttddlliibb..hh>>
_v_o_i_d _*
bbsseeaarrcchh(_c_o_n_s_t _v_o_i_d _*_k_e_y, _c_o_n_s_t _v_o_i_d _*_b_a_s_e, _s_i_z_e___t _n_m_e_m_b, _s_i_z_e___t _s_i_z_e,
_i_n_t _(_*_c_o_m_p_a_r_) _(_c_o_n_s_t _v_o_i_d _*_, _c_o_n_s_t _v_o_i_d _*_))
DDEESSCCRRIIPPTTIIOONN
The bbsseeaarrcchh() function searches an array of _n_m_e_m_b objects, the inital
member of which is pointed to by _b_a_s_e, for a member that matches the ob
ject pointed to by _k_e_y. The size of each member of the array is specified
by _s_i_z_e.
The contents of the array should be in ascending sorted order according
to the comparison function referenced by _c_o_m_p_a_r. The _c_o_m_p_a_r routine is
expected to have two two arguments which point to the _k_e_y object and to
an array member, in that order, and should return an integer less than,
equal to, or greater than zero if the _k_e_y object is found, respectively,
to be less than, to match, or be greater than the array member.
RREETTUURRNN VVAALLUUEESS
The bbsseeaarrcchh() function returns a pointer to a matching member of the ar
ray, or a null pointer if no match is found. If two members compare as
equal, which member is matched is unspecified.
SSEEEE AALLSSOO
db(3), lsearch(3), qsort(3),
SSTTAANNDDAARRDDSS
The bbsseeaarrcchh() function conforms to ANSI C3.1591989 (``ANSI C'').
BSD Experimental June 29, 1991 1