/* Version 0.0
** From "Wayne's Little DSA Library" (DSA == Data Structures and
** Algorithms) Feel free to change, modify, or burn these sources, but if
** you modify them please don't distribute your changes without a clear
** indication that you've done so.  If you think your change is spiffy,
** send it to me and maybe I'll include it in the next release.
**
** Wayne Hayes, wayne@csri.utoronto.ca (preffered), or wayne@csri.toronto.edu
*/

#include "misc.h"
#include "search.h"

void BinarySearch(const void *key, const void *a, size_t n, size_t w,
    pfnCmpFcn compare)
{
    bsearch(key, a, n, w, compare);
}

/***************************   END OF LIBRARY SOURCE *******************/

#if TEST_SORTS
#include <stdio.h>

#define TOTBYTES (4096*1024)
#define FooSize (4096)
#define NUM (TOTBYTES/FooSize)

typedef struct _foo {unsigned char i,j; unsigned char f[FooSize]; } FOO;

int FooCmp(const void *X, const void *Y)
{
    const FOO *x = X, *y = Y;
    int i;
    _compareCount++;
    if(x->i != y->i) return x->i - y->i;
    if(x->j != y->j) return x->j - y->j;

    for(i=0; i<FooSize; i++)
	if(x->f[i] != y->f[i]) return x->f[i] - y->f[i];

    return 0;
}

int FooCmpi(const void *X, const void *Y)
{
    const FOO *x = X, *y = Y;
    _compareCount++;
    return x->i - y->i;
}

int FooCmpj(const void *X, const void *Y)
{
    const FOO *x = X, *y = Y;
    _compareCount++;
    return x->j - y->j;
}

void FooDmp(const FOO *x)
{
    int i;
    printf("%d.%d[", x->i, x->j);
    for(i=0; i<FooSize; i++)
	printf("%d,", x->f[i]);
    printf("]");
}

int main(void)
{
}
#endif	/* TEST_SORTS */
