![kueller](/assets/img/avatar_default.png)
git-svn-id: svn://svn.compuextreme.de/Viitor/V961/Viitor_cc65@4236 504e572c-2e33-0410-9681-be2bf7408885
57 lines
2.0 KiB
HTML
57 lines
2.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.20">
|
|
<TITLE>cc65 function reference: Alphabetical function reference: bsearch</TITLE>
|
|
<LINK HREF="funcref-71.html" REL=next>
|
|
<LINK HREF="funcref-69.html" REL=previous>
|
|
<LINK HREF="funcref.html#toc3" REL=contents>
|
|
</HEAD>
|
|
<BODY>
|
|
<A HREF="funcref-71.html">Next</A>
|
|
<A HREF="funcref-69.html">Previous</A>
|
|
<A HREF="funcref.html#toc3">Contents</A>
|
|
<HR>
|
|
<H2><A NAME="bsearch"></A> 3.25 <A HREF="funcref.html#toc3.25">bsearch</A></H2>
|
|
|
|
|
|
<P>
|
|
<BLOCKQUOTE>
|
|
<DL>
|
|
<DT><B>Function</B><DD><P>Do a binary search in a sorted array.</P>
|
|
<DT><B>Header</B><DD><P><CODE>
|
|
<A HREF="funcref-38.html#stdlib.h">stdlib.h</A></CODE></P>
|
|
<DT><B>Declaration</B><DD><P><CODE>void* __fastcall__ bsearch (const void* key,
|
|
const void* base, size_t n, size_t size,
|
|
int (*cmp) (const void*, const void*));</CODE></P>
|
|
<DT><B>Description</B><DD><P><CODE>bsearch</CODE> searches a sorted array for a member that
|
|
matches the one pointed to by <CODE>key</CODE>. <CODE>base</CODE> is the address of the array,
|
|
<CODE>n</CODE> is the number of elements, <CODE>size</CODE> the size of an element and <CODE>cmp</CODE>
|
|
the function used to compare the members against the key. The function returns
|
|
a pointer to the member found, or <CODE>NULL</CODE> if there was no match.</P>
|
|
<DT><B>Limits</B><DD><P>
|
|
<UL>
|
|
<LI>The contents of the array must be sorted in ascending order according to
|
|
the compare function given.</LI>
|
|
<LI>If there are multiple members that match the key, the function will
|
|
return one of the members.</LI>
|
|
<LI>The function is only available as fastcall function, so it may only
|
|
be used in presence of a prototype.</LI>
|
|
</UL>
|
|
</P>
|
|
<DT><B>Availability</B><DD><P>ISO 9899</P>
|
|
<DT><B>See also</B><DD><P>
|
|
<A HREF="funcref-166.html#qsort">qsort</A></P>
|
|
<DT><B>Example</B><DD><P>None.</P>
|
|
</DL>
|
|
</BLOCKQUOTE>
|
|
</P>
|
|
|
|
|
|
<HR>
|
|
<A HREF="funcref-71.html">Next</A>
|
|
<A HREF="funcref-69.html">Previous</A>
|
|
<A HREF="funcref.html#toc3">Contents</A>
|
|
</BODY>
|
|
</HTML>
|