int search(int A[], int n, int target) { int k = _keyIndex(A, n); // n==0 or n > 0 bool positive = (A[0] <= A[k]); int u = _binarySearch(A, 0, k, positive, target); if(-1 == u) u = _binarySearch(A, k + 1, n - 1, positive, target); return u; }
int xdict_add(xdict *d, void *key, void *val) { int index; xdictEntry *entry; if ((index = _keyIndex(d, key)) == -1) return XDICT_ERR; entry = xmalloc(sizeof(*entry)); entry->next = d->table[index]; d->table[index] = entry; xdictSetHashKey(d, entry, key); xdictSetHashVal(d, entry, val); d->used++; return XDICT_OK; }