version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
BSEARCH |
|
|
2 |
!!!BSEARCH |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
CONFORMING TO |
|
|
8 |
SEE ALSO |
|
|
9 |
---- |
|
|
10 |
!!NAME |
|
|
11 |
|
|
|
12 |
|
|
|
13 |
bsearch - binary search of a sorted array. |
|
|
14 |
!!SYNOPSIS |
|
|
15 |
|
|
|
16 |
|
|
|
17 |
__#include |
|
|
18 |
__''key''__, const void *__''base''__, size_t__ ''nmemb''__, |
|
|
19 |
size_t__ ''size''__, int (*__''compar''__)(const void *, const void *)); |
|
|
20 |
__ |
|
|
21 |
!!DESCRIPTION |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
The __bsearch()__ function searches an array of |
|
|
25 |
''nmemb'' objects, the initial member of which is pointed |
|
|
26 |
to by ''base'', for a member that matches the object |
|
|
27 |
pointed to by ''key''. The size of each member of the |
|
|
28 |
array is specified by ''size''. |
|
|
29 |
|
|
|
30 |
|
|
|
31 |
The contents of the array should be in ascending sorted |
|
|
32 |
order according to the comparison function referenced by |
|
|
33 |
''compar''. The ''compar'' routine is expected to have |
|
|
34 |
two arguments which point to the ''key'' object and to an |
|
|
35 |
array member, in that order, and should return an integer |
|
|
36 |
less than, equal to, or greater than zero if the ''key'' |
|
|
37 |
object is found, respectively, to be less than, to match, or |
|
|
38 |
be greater than the array member. |
|
|
39 |
!!RETURN VALUE |
|
|
40 |
|
|
|
41 |
|
|
|
42 |
The __bsearch()__ function returns a pointer to a |
|
|
43 |
matching member of the array, or NULL if no match is found. |
|
|
44 |
If there are multiple elements that match the key, the |
|
|
45 |
element returned is unspecified. |
|
|
46 |
!!CONFORMING TO |
|
|
47 |
|
|
|
48 |
|
|
|
49 |
SVID 3, BSD 4.3, ISO 9899 |
|
|
50 |
!!SEE ALSO |
|
|
51 |
|
|
|
52 |
|
|
|
53 |
qsort(3) |
|
|
54 |
---- |