summaryrefslogtreecommitdiffstats
path: root/src/vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/vector.h')
-rw-r--r--src/vector.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/vector.h b/src/vector.h
index 701b64e..0396c01 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -81,3 +81,10 @@ void _fastd_vector_delete(fastd_vector_desc_t *desc, void **data, size_t pos, si
__typeof__(v) *_v = &(v); \
_fastd_vector_delete(&_v->desc, (void**)&_v->data, (pos), sizeof(*_v->data)); \
})
+
+#define VECTOR_BSEARCH(key, v, cmp) ({ \
+ __typeof__(v) *_v = &(v); \
+ const __typeof__(*_v->data) *_key = (key); \
+ int (*_cmp)(__typeof__(_key), __typeof__(_key)) = (cmp); \
+ (__typeof__(_v->data))bsearch(_key, _v->data, _v->desc.length, sizeof(*_v->data), (int (*)(const void *, const void *))_cmp); \
+ })