Last change
on this file since 80 was
80,
checked in by Sam Hocevar, 14 years ago
|
- Adding the Golgotha source code. Not sure what's going to be interesting
in there, but since it's all public domain, there's certainly stuff to
pick up.
|
File size:
1.1 KB
|
Rev | Line | |
---|
[80] | 1 | /********************************************************************** <BR>
|
---|
| 2 | This file is part of Crack dot Com's free source code release of
|
---|
| 3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
| 4 | information about compiling & licensing issues visit this URL</a>
|
---|
| 5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
| 6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
| 7 | ***********************************************************************/
|
---|
| 8 |
|
---|
| 9 | #include "inc/search.hh"
|
---|
| 10 |
|
---|
| 11 | i4_bool i4_base_bsearch(const void *member, w32 &loc,
|
---|
| 12 | const void *array, w32 member_size, w32 size,
|
---|
| 13 | int (*compare)(const void *a, const void *b))
|
---|
| 14 | {
|
---|
| 15 | w32 l=0,r=size,m;
|
---|
| 16 | int c;
|
---|
| 17 |
|
---|
| 18 | while (l<r)
|
---|
| 19 | {
|
---|
| 20 | m = (l+r)/2;
|
---|
| 21 |
|
---|
| 22 | if ((c = compare(member, (void*)((w8*)array+member_size*m)))==0)
|
---|
| 23 | {
|
---|
| 24 | loc = m;
|
---|
| 25 | return i4_T;
|
---|
| 26 | }
|
---|
| 27 | else if (c<0)
|
---|
| 28 | r = m;
|
---|
| 29 | else
|
---|
| 30 | l = m+1;
|
---|
| 31 | }
|
---|
| 32 | loc = l;
|
---|
| 33 | if (l<size && compare(member, (void*)((w8*)array+member_size*l))==0)
|
---|
| 34 | return i4_T;
|
---|
| 35 | return i4_F;
|
---|
| 36 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.