40 int (*compare)(
const void *c1,
const void *c2), int32_t *duplicate) {
41 long ih, il, im, comparison;
51 if ((comparison = (*compare)(array[il], newMember)) >= 0) {
52 if (comparison == 0) {
57 }
else if ((comparison = (*compare)(array[ih], newMember)) <= 0) {
58 if (comparison == 0) {
64 while ((ih - il) > 1) {
66 if ((comparison = (*compare)(array[im], newMember)) == 0) {
77 for (il = members; il > im; il--)
78 array[il] = array[il - 1];
79 array[im] = newMember;
99 int (*compare)(
const void *c1,
const void *c2),
long bracket) {
100 long ih, il, im, comparison;
107 if ((comparison = (*compare)(array[il], key)) >= 0) {
111 }
else if ((comparison = (*compare)(array[ih], key)) <= 0) {
116 while ((ih - il) > 1) {
118 if ((comparison = (*compare)(array[im], key)) == 0)
131 comparison = (*compare)(array[im], key);
134 comparison = (*compare)(array[il], key);
157 int (*compare)(
const void *c1,
const void *c2),
long bracket)
162 long ih, il, im, comparison;
169 if ((comparison = (*compare)((
void *)((
char *)array + il * elemSize), key)) >= 0) {
173 }
else if ((comparison = (*compare)((
void *)((
char *)array + ih * elemSize), key)) <= 0) {
178 while ((ih - il) > 1) {
180 if ((comparison = (*compare)((
void *)((
char *)array + im * elemSize), key)) == 0)
193 comparison = (*compare)((
void *)((
char *)array + im * elemSize), key);
196 comparison = (*compare)((
void *)(((
char *)array) + il * elemSize), key);
long binaryInsert(void **array, long members, void *newMember, int(*compare)(const void *c1, const void *c2), int32_t *duplicate)
Inserts a new member into a sorted array using binary search.
long binaryArraySearch(void *array, size_t elemSize, long members, void *key, int(*compare)(const void *c1, const void *c2), long bracket)
Searches for a key in a sorted array of data values using binary search.
long binaryIndexSearch(void **array, long members, void *key, int(*compare)(const void *c1, const void *c2), long bracket)
Searches for a key in a sorted array of pointers using binary search.