?? binary.c
字號:
/* * binary() * search and maintain a sorted array */#include <string.h>#include "binary.h"void * binary (const void * key, void * _base, size_t * nelp, size_t width, int (* cmp) (const void * key, const void * elt)){ size_t nel = * nelp;#define base (* (char **) & _base) char * lim = base + nel * width, * high; if (nel > 0) { for (high = lim - width; base <= high; nel >>= 1) { char * mid = base + (nel >> 1) * width; int c = cmp(key, mid); if (c < 0) high = mid - width; else if (c > 0) base = mid + width, -- nel; else return (void *) mid; } memmove(base + width, base, lim - base); } ++ *nelp; return memcpy(base, key, width);#undef base}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -